import pandas as pd
# Get stock data from excel
file_path = pd.read_csv("C:\Users\OneDrive\Desktop\nifty1.csv")
#show the data
df = pd.read_csv(file_path)
print(df.head())
我得到的代码错误是
File "<ipython-input-59-276db8347c3f>", line 4
file_path = pd.read_csv("C:\Users\OneDrive\Desktop\nifty1.csv")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
1条答案
按热度按时间yqhsw0fo1#
字符串
"\U"
在Python中有特殊的含义。或者通过在前面放置
r
将其更改为原始字符串:或者使用正斜杠代替反斜杠: