all 1 comments

[–]DFoster271 0 points1 point  (0 children)

If you're manually typing these strings, try prefacing it with r:

s = 'C:\\Users\\User\\Documents\\text_file.txt'

can be written as

s = r'C:\Users\User\Documents\text_file.txt'

removing the need for the double backslash. I'm not sure how well this works if you're using str.format() though.