0
我是編程新手,這是我用python編寫的第二個腳本。該代碼在我的編程環境中正常工作。然而,當我在cmd中運行它,我得到以下錯誤:Errno 22無效的參數
Traceback (most recent call last): File
"C:\FS1\Python\Stiffness_punch\main.py", line 34, in <module>
with open(project_status) as f: IOError: [Errno 22] Invalid argument: '004.pch\r'
下面是代碼:
print('Specify the name of the status project .pch file')
project_status = input("")
with open(project_status) as f:
status_lines = f.readlines()
我無法找到任何解決方案。據我瞭解文件的名稱被解釋爲「004.pch \ r」而不是「004.pch」,但我不知道如何從文件的名稱中刪除這"\r"
。
的可能的複製[Python的 「IO錯誤:\ [錯誤22 \]無效參數」 使用的cPickle當寫大陣列以網絡驅動器(http://stackoverflow.com/ questions/4226941/python-ioerror-errno-22-invalid-argument-when-using-cpickle-to-write-large) – apxp
需要使用分片操作刪除「\ r」。 –
你可以請你說明你如何把輸入的腳本放在cmd中? – shaktimaan