值错误:无效 \x 转义: [英] ValueError: invalid \x escape:
问题描述
ValueError: invalid \x escape:
File "SConstruct", line 49:
execfile("hosts.cfg")
我完全被这个家伙难住了......
I'm completely stumped with this one guys...
如果我在第 49 行之前打印,我可以看到输出.在hosts.cfg"的第一行,我放置了第二个从未执行过的打印语句.
If I print right before line 49, I can see the output. On the very first line of "hosts.cfg" I put a second print statement which is never executed.
推荐答案
即使在 Windows 上,正斜杠也适用于目录名称,因此您可以对这些名称进行标准化:
Even on Windows, forward slashes should work for directory names, so you could standardize on those:
"libpath" : [".", "../xlib", "../tools", "../info"],
或者使用原始字符串,正如@Adam Rosenfield 在评论中已经说过的:
Or use raw strings, as @Adam Rosenfield already said in a comment:
"libpath" : [r".", r"..\xlib", r"..\tools", r"..\info"],
我认为上述两种解决方案都比将所有反斜杠加倍更好,并且加载比仅对以x"开头的目录名称加倍反斜杠更好.
I think both of the above solutions are better than doubling all the backslashes, and loads better than just doubling backslashes for directory names that start with 'x'.
这篇关于值错误:无效 \x 转义:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!