Never use use single backslash (
\
) that way in path,because of escape character.\U
starts an eight-character Unicode escape in Python 3.Error:>>> s = 'C:\Users\DSule\Desktop\python\nyc.csv'
Traceback (most recent call last):
.........
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
Here are three ways that work.>>> # Raw string(r) >>> s = r'C:\Users\DSule\Desktop\python\nyc.csv' >>> s 'C:\\Users\\DSule\\Desktop\\python\\nyc.csv' >>> # Other way / >>> s = 'C:/User/DSule/Desktop/python/nyc.csv' >>> s 'C:/User/DSule/Desktop/python/nyc.csv' >>> # Double up >>> s = 'C:\\Users\\DSule\\Desktop\\python\\nyc.csv' >>> s 'C:\\Users\\DSule\\Desktop\\python\\nyc.csv'