Python:前面声明该行的变量的“意外令牌文件名”

时间:2014-09-03 17:49:34

标签: python visual-studio

我有这段代码,出于某种原因,Visual Studio是filename print filename中的invalid syntax所说"意外的令牌文件名"。当我尝试编译它时抛出import os for filenames in os.listdir(r'C:\Users\output'): for filename in filenames: print filename

filename

{I}如何申报Traceback (most recent call last): File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 1 06, in exec_file exec_code(code, file, global_variables) File "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensio ns\Microsoft\Python Tools for Visual Studio\2.1\visualstudio_py_util.py", line 8 1, in exec_code code_obj = compile(code, file, 'exec') File "C:\Users\user\Selenium\stockDataFormater(PY)\stockDataFormater(PY)\stock DataFormater.py", line 5 print filename ^ SyntaxError: invalid syntax ,因为我刚才宣布它为行?

完整错误消息:

{{1}}

0 个答案:

没有答案