电脑上有两个python,在pycharm创建django时出错

2025-04-15 13:41:36
推荐回答(1个)
回答1:

26down voteaccepted

Use forward slashes:
'path/regionlog.txt'

Or raw strings:
r'path\regionlog.txt'

Or at least escape your backslashes:
'path\\regionlog.txt'

\r is a carriage return.

Another option: use os.path.join and you won't have to worry about slashes at all:
output = os.path.abspath(os.path.join('path', 'regionlog.txt'))