Cannot run python script [duplicate]

ⅰ亾dé卋堺 提交于 2019-12-25 18:43:23

问题


I am trying to run this python script:

https://gist.githubusercontent.com/nk9/b150542ef72abc7974cb/raw/4a1e249976c6c330116fc068fb7001e3443c5b8d/largestFiles.py

but for some reason it contains a bunch of illegal characters and gives this error:

C:\tools\inspect>python largestFiles.py
  File "largestFiles.py", line 28
    print "Finding objects larger than {}kB\u2026".format(args.filesExceeding)
                                            ^
SyntaxError: invalid syntax

If I remove those illegal characters I still get:

C:\tools\inspect>python largestFiles.py
  File "largestFiles.py", line 28
    print "Finding objects larger than {}".format(args.filesExceeding)
                                         ^
SyntaxError: invalid syntax

Any ideas?

I am running it on windows 8 using python 3.4


回答1:


As print is function in python 3 you need to put your string in parenthesis. https://docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function

>>> print ("Finding objects larger than kB\u2026")
Finding objects larger than kB…


来源:https://stackoverflow.com/questions/29627895/cannot-run-python-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!