首页 > 解决方案 > 笔记本中的 Python 错误代码,[Errno 22] 无效参数:'.....\test python.xlsx'

问题描述

我正在尝试使用 Pandas 将 xlsx 文件读入 Python。

如果你看到代码,我发现了一个问题。第一个 pd.read_excel() 可以工作,但第二个不行。两者都是相似的代码行,但第二个 pd.read_excel() 不会读取 xlsx 文件

import pandas as pd

df = pd.read_excel (r"D:\Users\act_gwj\Downloads\test python.xlsx") #- this will work
df = pd.read_excel (r"‪D:\Users\act_gwj\Downloads\test python.xlsx") # - this doesn't
print (df) 

错误:

OSError: [Errno 22] Invalid argument: '\u202aD:\\Users\\act_gwj\\Downloads\\test python.xlsx'

我在 Anaconda Notebook 32 位上使用 Python 3.6.5。熊猫版本 0.25.1

提前致谢

标签: python

解决方案


推荐阅读