在我正在處理的項目中,我必須加載幾十個圖像。但是,如果我嘗試加載任何人,像這樣的:語法unicode錯誤pygame
twoc = pygame.image.load("C:\Users\Z & Z Azam\AppData\Local\Programs\Python\Python35\Scripts\Cards\2_of_clubs.png")
我得到這個消息:
"C:\Users\Z & Z Azam\AppData\Local\Programs\Python\Python35\python.exe" "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py"
File "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py", line 16
twoc = pygame.image.load("C:\Users\Z & Z Azam\AppData\Local\Programs\Python\Python35\Scripts\Cards\2_of_clubs.png") # Lines 15-66 bring all the cards into the program
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
我不知道我做錯了什麼。有沒有人可以幫助我?
更新:所以我走了,用/替換文件中的每個\地址。再次,它完美的工作,直到:
"C:\Users\Z & Z Azam\AppData\Local\Programs\Python\Python35\python.exe" "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py"
Traceback (most recent call last):
File "C:/Users/Z & Z Azam/Desktop/New folder (2)/Python Stuff/PycharmProjects/ProjectGambler/Graphics-Cards.py", line 28, in <module>
fivc = pygame.image.load("C:/Users/Z & Z Azam/AppData/Local/Programs/Python/Python35/Scripts/Cards/5_of_clubs")
pygame.error: Couldn't open C:/Users/Z & Z Azam/AppData/Local/Programs/Python/Python35/Scripts/Cards/5_of_clubs
Process finished with exit code 1