How to put an actual backslash in a string in Python

2 Answers

0 votes
path = "C:\\Users\\ZigZag\\Desktop"
 
print(path)
 
 

'''
run:
 
C:\Users\ZigZag\Desktop
 
'''

 



answered Sep 14 by avibootz
edited Sep 14 by avibootz
0 votes
path = 'C:' + r'\Users' r'\ZigZag' + r'\Desktop'

print(path)


'''
run:

C:\Users\ZigZag\Desktop

'''

 



answered Sep 14 by avibootz

Related questions

1 answer 246 views
1 answer 178 views
1 answer 191 views
2 answers 238 views
...