python在环境变量路径中引发语法错误

Matthijs990

我有这个环境变量:VAR=C:\Users\User但是"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape当我尝试时,如何防止python给这个错误:

import os
os.environ["VAR"]

无需在命令行中更改变量

雷蒙德

添加r使编译器知道它是原始字符串。

r'{}'。format(os.environ [“ VAR”]))

但是,您的代码在我这边工作,没有任何更改。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章