问题:
  windows平台下使用python open函数w模式打开文件报错“OSError: [Errno 22] Invalid argument: '../news/“消费升维”成零售业新风口?渠道多元同步跟进.txt'”
 
解决:
  本来猜测是转义符的问题,但是使用python原字符串仍然不能解决问题。
  后来发现其实是windows下文件的命名存在限制:
    在Windows系统中,文件名不允许使用的字符有: < > / \ | : " * ?
 
  在Windows系统中,文件名命名规则如下:
    1)文件名最长可以使用255个字符;
    2)可以使用扩展名,扩展名用来表示文件类型,也可以使用多间隔符的扩展名(如win.ini.txt是一个合法的文件名,但其文件类型由最后一个扩展名决定);
    3)文件名中允许使用空格,但不允许使用下列字符(英文输入法状态):< > / \ | : " * ?;
    4)windows系统对文件名中字母的大小写在显示时有不同,但在使用时不区分大小写。

Python创建文件报错OSError:[Errno 22] Invalid argument处理的更多相关文章

  1. 【Selenium】【BugList9】windows环境,fp = open("./"+ time.strftime("%Y-%m-%d %H:%M:%S") + " result.html",'wb'),报错:OSError: [Errno 22] Invalid argument: './2018-09-05 10:29:32 result.html'

    [代码] if __name__=="__main__": suite = unittest.TestSuite() suite.addTest(Baidu("test_ ...

  2. 在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: ‘文件路径’

    如题,在使用python语言的open函数时,提示错误OSError: [Errno 22] Invalid argument: '文件路径',在查阅了大量资料后也得到了一些解决方案,但是这些解决方案 ...

  3. python使用open的OSError: [Errno 22] Invalid argument错误

    这两天在写一个新闻类的spider时,遇到了OSError: [Errno 22] Invalid argument这个错误,苦恼的两天,无果.后来通过请教学长,发现原来是打开的文件名中含有一些系统的 ...

  4. Python报错IOError: [Errno 22] invalid mode ('r') or filename

    IOError: [Errno 22] invalid mode ('r') or filename: 这种错误的出现是在使用built-in函数file()或者open()的时候. 或者是因为文件的 ...

  5. 【Selenium + Python】路径报错之OSError: [Errno 22] Invalid argument: './t/report/2018-03-23_11:03:12_report.html'

    现象: 此问题真的是太痛苦了,查了好多资料是说路径的问题,结果还是报错,后来一点点的排查才发现原来是!!!!!! 废话不多说上原来代码: if __name__ == '__main__': star ...

  6. python OSError: [Errno 22] Invalid argument: '\u202aF://text

    windows10 python3 读文件的时候报的错误 原因不明时好时坏很头疼但又没办法不知道怎么解决,网上的说法都不能解决,

  7. python OSError: [Errno 22] Invalid argument: 'D:\\crawle\x01.html1'

    import urllib.request file = urllib.request.open("http://www.baidu.com") data = file.read( ...

  8. OSError: [Errno 22] Invalid argument: 'D:\x07ckup\test.txt'

    使用with open("D:\backup\test.txt","rt") as f:报上面的错误,将上面的语句改成 with open(r"D:\ ...

  9. tensorboard OSError:[Errno 22] Invalid argument

    哈哈 问题解决了.感谢大佬 Bill.Z 附上原文链接:https://blog.csdn.net/u013244846/article/details/88380860 解决方法:更改manager ...

随机推荐

  1. 四十六.系统审计 服务安全 Linux安全之打补丁

    192.168.4.51   1.部署audit监控文件 使用audit监控/etc/ssh/sshd_config 当该文件发生任何变化即记录日志 通过手动和ausearch工具查看日志内容   1 ...

  2. 使用 ServerSocket 建立聊天服务器-1

    1.代码目录 2.ChatSocket.java --------------------------------------------------------------------------- ...

  3. jsp利用webuploader实现超大文件分片上传、断点续传

    1,项目调研 因为需要研究下断点上传的问题.找了很久终于找到一个比较好的项目. 在GoogleCode上面,代码弄下来超级不方便,还是配置hosts才好,把代码重新上传到了github上面. http ...

  4. Codeforces Round #589 (Div. 2)

    目录 Contest Info Solutions A. Distinct Digits B. Filling the Grid C. Primes and Multiplication D. Com ...

  5. Codeforces Round #525 (Div. 2)题解

    Codeforces Round #525 (Div. 2)题解 题解 CF1088A [Ehab and another construction problem] 依据题意枚举即可 # inclu ...

  6. [转]引用模板类中定义的类型(用typedef或using)以及auto、decltype、typename的使用

    一.背景 使用typedef或者using定义类型别名是非常常见的手段,在c++里面,有时为了封装性,模块性等原因还会在某一个namespace或者class内部定义类型别名. 最近在写c++代码的时 ...

  7. LUA 在C函数中保存状态:registry、reference

    1 背景 lua的值一般都是保存在栈里面,调用函数完毕值在栈会被清掉,从而被GC回收.但有时候C函数需要在函数体的作用域之外保存某些Lua数据,这些数据不能存放在栈里面,有没有全局变量之类的可以存放. ...

  8. Solr 集成ikanalyzer

    Solr 不能对中文进行分词,ikanalyzer可以. ikanalyzer下载链接 1.下载 jar形式 2.放到D:\soft\solr-8.1.0\server\solr-webapp\web ...

  9. git补充(关于pull request)转自知乎

    当你想更正别人仓库里的错误时,要走一个流程: 1先 fork 别人的仓库,相当于拷贝一份,不会有人直接让你修改原仓库的 2.clone 到本地分支,做一些 bug fix 3.发起 pull requ ...

  10. delphi 解决android 9上无法使用http协议

    delphi 解决android 9上无法使用http协议 安卓9不让客户端通过非https方式访问服务端数据(不允许发送明文http请求)的问题. 解决方法: 1.选择安卓平台编译一次程序,在项目根 ...