简体   繁体   中英

How to read csv file in pandas if the pathname contains single inverted comma and i get error?

My Code:

df1=pd.read_csv(r'C:\Users\YUNUS'S LAPTOP\Desktop\Book1.csv')
df1

Error I get:

  Input In [20]
    df1=pd.read_csv(r'C:\Users\YUNUS'S LAPTOP\Desktop\Book1.csv')
                                     ^
SyntaxError: invalid syntax

use " rather than ' for the bonds of the string, like so

df1 = pd.read_csv(r"C:\Users\YUNUS'S LAPTOP\Desktop\Book1.csv")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM