Ich habe gerade ein Problem Umlaute in Python darzustellen und weiß einfach nicht, wieso es nicht klappt.
Windows 10
Python 3.10.9
Visual Studio 22 Community Edition
Standartformat ist UTF-8
Code: Alles auswählen
C:\Users\Christoph>python
Python 3.10.9 (tags/v3.10.9:1dd9be6, Dec 6 2022, 20:01:21) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.getdefaultencoding())
utf-8
>>>
Code: Alles auswählen
# -*- coding: utf-8 -*-
print("Hauptmenü")
Code: Alles auswählen
Traceback (most recent call last):
File "C:\Users\Christoph\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Christoph\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\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/..\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/..\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
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\Christoph\source\repos\PythonApplication2023\PythonApplication2023\PythonApplication2023.py", line 1
print("Hauptmen�")
^
SyntaxError: (unicode error) 'utf-8' codec can't decode byte 0xfc in position 8: invalid start byte