首頁  >  問答  >  主體

初學Python,debug時報錯,不知道原因在哪?

在pycharm下寫的.
報錯訊息如下:

C:\Python27\python.exe "C:\Program Files\JetBrains\PyCharm 2017.1.2\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 51755 --file E:/python/first.py
pydev debugger: process 4988 is connecting

Connected to pydev debugger (build 171.4249.47)
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2017.1.2\helpers\pydev\pydevd.py", line 1585, in <module>
    globals = debugger.run(setup['file'], None, None, is_module)
  File "C:\Program Files\JetBrains\PyCharm 2017.1.2\helpers\pydev\pydevd.py", line 1015, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "E:/python/first.py", line 3
SyntaxError: Non-ASCII character '\xe7' in file E:/python/first.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Process finished with exit code 1

後來自己回憶了一下,是我大意了..記得第一次debug的時候,

#是要修改下圖圈內的檔案路徑的,當我修改完檔案路徑之後,程式可以運行了.
所以每次創建新程式debug的時候,都要手動在這裡修改檔案路徑嗎?

某草草某草草2710 天前697

全部回覆(2)我來回復

  • PHPz

    PHPz2017-05-19 10:09:02

    File "E:/python/first.py", line 3
    SyntaxError: Non-ASCII character 'xe7' in file E:/python/first.py on line 3, but no encoding deced;

    這裡的問題,第三行,中文解碼錯誤,是不是用了中文的標點符號

    回覆
    0
  • 巴扎黑

    巴扎黑2017-05-19 10:09:02

    代碼中用了中文逗號,換成英文格式就好。提示裡有指出。

    回覆
    0
  • 取消回覆