Python_報錯:SyntaxError: EOL while scanning string literal
原因:python中,目錄操作時,字符串的最后一個字符是斜杠,會導致出錯,去掉\即可
上代碼
>>> import os >>> os.chdir(r"e:\")#字符串的最后一個字符是斜杠,會導致出錯 File "<stdin>", line 1 os.chdir(r"e:\") ^ SyntaxError: EOL while scanning string literal
解決方法:去掉最后的\即可
>>> import os >>> os.chdir(r"e:") >>>