惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
Y
Y Combinator Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
The GitHub Blog
The GitHub Blog
N
Netflix TechBlog - Medium
MyScale Blog
MyScale Blog
F
Fortinet All Blogs
Microsoft Azure Blog
Microsoft Azure Blog
H
Help Net Security
C
Check Point Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
M
MIT News - Artificial intelligence
U
Unit 42
WordPress大学
WordPress大学
B
Blog
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
D
DataBreaches.Net
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家

博客园 - 晨光静默

centos 命令 curl用到的一些命令 nginx记录 html select qq作文 mfc开启控制台打印日记 mfc右键菜单(包括系统托盘菜单)弹窗后如何消失 angular单页应用点击button自动刷新页面 setTimeout中调用angular的作用域生效 mfc模态对话框和非模态对话框注意点 c/c++元转分的bug c/c++中的崩溃代码片段 查看网络端口连接情况 win7x64安装python运行报错:api-ms-win-crt-runtime-|1-1-0.dll qt导入头文件报错 python记录 (转)Curl命令详解 开箱即用的clogger 异步重叠IO linux xshell 命令上传下载文件 png转CBitmap
SyntaxError: (unicode error) 'unicodeescape' code...
晨光静默 · 2023-05-12 · via 博客园 - 晨光静默

运行程序直接闪退退出,编译器运行提示:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 275-276: truncated \xXX escape

网上查询一堆说是代码中路径问题,但代码中路径确实是正确路径,有r或者\\或者/的,试了好久都未能找到。

分析:发现第一行代码都未能输出,正常连第一行的print都未能输出,说明pyhton是先整体编译代码后再运行?

找了好久终于找到,是把一行#注释移动到函数头断注释里面了,最终还是路径原因。

原来的注释:

#E:\xx\20230425\xxdir

移动到函数头注释里面就直接咯咯了

    ''' 

    处理每个目录信息

    E:\xx\20230425\xxdir   <- 罪魁祸首的地方,这是导致报错的原因,把所有\改成/就不会报错了

    '''  

相信网上这种报错还是头一次把,千篇一律没找到这种情况。算是吃了个歪螃蟹。