问题:
  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. Elasticsearch 调优之 搜索速度优化

    本章讨论搜索速度优化:搜索速度与系统资源.数据索引方式.查询方式等多方面 1.为文件系统cache预留足够的内存 1)应用程序一般情况下,读写都会被操作系统“cache” 2)cache保存在物理内存 ...

  2. learning scala view collection

    The view method will create a non-strict version of the collection which means that the elements of ...

  3. hdu 5452

    无意中看到这道题 没读懂英文题面 百度题解寻找题面 看到: #include <iostream> #include <cstdio> #include <algorit ...

  4. link cut tree 洞穴勘测

    /*[bzoj2049][Sdoi2008]Cave 洞穴勘测 2014年7月30日1,06923Description 辉辉热衷于洞穴勘测.某天,他按照地图来到了一片被标记为JSZX的洞穴群地区 . ...

  5. mybatis oracle 逆向工程

  6. json页面解析

    List<TjfxDTO> cyjbList = new ArrayList<TjfxDTO>(); cyjbList=tjfxService.cyjb_wcjd(tjfxDT ...

  7. Android Handler消息处理顺序分析

    看到Handler中的消息处理函数: public void dispatchMessage(Message msg){...} 这个函数是在Looper的执行消息循环loop()的时候取出Messa ...

  8. 关于 Win10 下使用 IETester 的问题

    真没想到,现在都用上Win10了,居然还会有使用 IETester 的需求,今天一个客户反应界面出现变形.错位的情况,于是又想到了这个老古董,去它的官网一看,果然N年没更新了! 抱着试试看的心理,下载 ...

  9. Git git rm和git rm --cached

    git rm 和 git rm --cached 的区别 git rm file git commit -m "xxx" git push origin master 删除本地及仓 ...

  10. arcgis python ListEnvironments 函数可返回地理处理环境名称列表。

    import arcpy environments = arcpy.ListEnvironments() # Sort the environment names environments.sort( ...