如何在python字符串中写\ [重复]

问题描述 投票:0回答:1

如何在python中写\

当我编写此代码时:

loc = os.path.abspath(os.path.dirname(__file__)) + '\pics' + '\' + file_name

我遇到此错误:

  File ".\main.py", line 7
    loc = os.path.abspath(os.path.dirname(__file__)) + '\pics' + '\' + file_name
                                                                               ^
SyntaxError: EOL while scanning string literal
python
1个回答
-1
投票
loc = os.path.abspath(os.path.dirname(__file__)) + '\pics' + '\' + str(filename) 
© www.soinside.com 2019 - 2024. All rights reserved.