简体   繁体   中英

Tkinter: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

So I have been trying to set an image to tkinter but it doesn't work.

info:

  • the resolution is on 256x256
  • the image is converted to .ico
  • I used iconbitmap

the code is this:

crk.iconbitmap('D:\somewhere\someone\somewhere\somewhere\projects\crackapss\logo.ico')

the error is this:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

使用双反斜杠或单正斜杠

crk.iconbitmap('D:\\somewhere\\someone\\somewhere\\somewhere\\projects\\crackapss\\logo.ico')
crk.iconbitmap('D:/somewhere/someone/somewhere/somewhere/projects/crackapss/logo.ico')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM