Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backslashes in Windows filepath? [duplicate]

Tags:

python

windows

When setting a string to a filepath in Python for WIndows, does it need to be formatted as:

C:\\Users\\

Or do escapes not apply on Windows? My script is currently giving me something like "Non-ASCII character" at the line import os, so I can't really test this.

like image 886
tkbx Avatar asked Oct 29 '25 11:10

tkbx


1 Answers

Try adding an "r", do as below:

path = r"C:\mypaht\morepaht\myfie.file"
like image 114
Netwave Avatar answered Nov 01 '25 02:11

Netwave