import os
xp1 = "\Documents and Settings\"
xp2 = os.getenv("USERNAME")
print xp1+xp2
给我错误
File "1.py", line 2
xp1 = "\Documents and Settings\"
^
SyntaxError: EOL while scannning single-quoted string
你能帮帮我吗,你看到问题了吗?
原文由 Python 发布,翻译遵循 CC BY-SA 4.0 许可协议
反斜杠字符被解释为转义符。对 Windows 路径使用双反斜杠: