Python IOError: [Errno 22] 无效模式 ('wb') 或文件名:

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22620965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 01:17:38  来源:igfitidea点击:

IOError: [Errno 22] invalid mode ('wb') or filename:

pythonfile-ioioerror

提问by user3369317

I keep getting the following error.

我不断收到以下错误。

IOError: [Errno 22] invalid mode ('wb') or filename: 'C:\Users\Viral Patel\Documents\GitHub\3DPhotovoltaics\Data_Output\Simulation_Data\Raw_Data\Raw_Simulation_Data_2014-03-24 17:21:20.545000.csv'

I think it is due to the timestamp at the end of the filename. Any ideas?

我认为这是由于文件名末尾的时间戳。有任何想法吗?

采纳答案by Martijn Pieters

You cannot use :in Windows filenames, see Naming Files, Paths, and Namespaces ; it is one of the reserved characters:

您不能:在 Windows 文件名中使用,请参阅命名文件、路径和命名空间;它是保留字符之一:

  • The following reserved characters:

    • <(less than)
    • >(greater than)
    • :(colon)
    • "(double quote)
    • /(forward slash)
    • \(backslash)
    • |(vertical bar or pipe)
    • ?(question mark)
    • *(asterisk)
  • 以下保留字符:

    • <(少于)
    • >(比...更棒)
    • :(冒号)
    • "(双引号)
    • /(正斜杠)
    • \(反斜杠)
    • |(垂直条或管)
    • ?(问号)
    • *(星号)

Use a different character not on the reserved character list.

使用不在保留字符列表中的不同字符。