2025年6月1日 星期日

visual studio python 有中文就失敗 編碼錯誤

因為找到的解法是簡體中文,所以這裡提供繁體中文版的


工具-->自訂

命令-->功能表列-->檔案-->加入命令-->檔案-->進階儲存選項-->確定





錯誤訊息很長,但實測就是有中文就會跳錯誤

----------------------------------------------------------------------

 Traceback (most recent call last):

  File "C:\Users\vincent\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main

    return _run_code(code, main_globals, None,

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\vincent\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in _run_code

    exec(code, run_globals)

  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy\__main__.py", line 39, in <module>

    cli.main()

  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main

    run()

  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file

    runpy.run_path(target, run_name="__main__")

  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 320, in run_path

0x1 執行緒以返回碼 0 (0x0) 結束。

    code, fname = _get_code_from_file(run_name, path_name)

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 294, in _get_code_from_file

    code = compile(f.read(), fname, 'exec')

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\vincent\source\repos\PythonApplication0327\PythonApplication0327\PythonApplication0327.py", line 1

    print("123  @")

                  ^

SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xa4 in position 4: invalid start byte

'python.exe' 程式以返回碼 4294967295 (0xffffffff) 結束。

沒有留言:

張貼留言

GOOGLE不小心按了改成韓文,改變語言設定

  好奇點了上面的其他語言版本,結果搞了一會才改回中文,提供修改流程給需要的人