When using the python language open function, an error OSError: [Errno 22] Invalid argument: 'file path'

If that, when using the python language open function, an error OSError: [Errno 22] Invalid argument: 'file path', after reviewing a lot of information has also been a number of solutions, but these solutions in the case of the author are not applicable, still being given, no way, although the author's English level very loud noise, but the Chinese can not help author, I had to resort to the English.

       Suggest that spectators in the modification, careful look at their own situation if applicable. Ado, start text.

       On the path to the open ( 'D: \ LearningBooks \ test.txt')

       Error when you use because the path is copied directly from the Windows file directory over, in python \ is the escape character, the author file \ test.txt in, \ t is a tab character, in order to properly use paths need to change the form D:\LearningBooks\\test.txt, or r‘D:\LearningBooks\test.txt’.

       Or D:/LearningBooks/test.txt即直接用斜杠/不用反斜杠\.

       This is actually very important in multiple languages, wrote this article is to remind myself to pay attention to the path of writing specifications.

Transfer: https://blog.csdn.net/qq_33363973/article/details/77862007

Guess you like

Origin www.cnblogs.com/Terrypython/p/11494582.html