Python报错:‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UXXXXXXXX escape

  • 在文件夹中复制地址时,文件夹中的地址是用 \ 来分隔不同文件夹的,而Python识别地址时只能识别用 / 分隔的地址

  • 解决方法

    1.在字符串前加上rR

  • 其中r或R在python中表示一个不转义的字符串。
  • 2.在“\”前加上”\”实现转义。

  • 3.将“\”换为“/”

  • 最后:补充一下python字符串前缀的知识

  • 1、在字符串前加上rR表示该字符串是非转义的原始字符串。
  • 2、在字符串前加上uU表示该字符串是unicode字符串

(47条消息) Python报错:‘unicodeescape‘ codec can‘t decode bytes in position 2-3: truncated \UXXXXXXXX escape_骑着蜗牛ひ追导弹'的博客-CSDN博客_unicodeescapeicon-default.png?t=M85Bhttps://blog.csdn.net/qq_45797116/article/details/110423429

猜你喜欢

转载自blog.csdn.net/m0_56312629/article/details/127406234