相关疑难解决方法(0)

Python - 验证我的文档xls中是否存在工作表

我正在尝试在我的空闲时间设计一个小程序,它加载一个xls文件,然后在要扫描的文档中选择一个工作表.

第1步:用户导入.xls文件.导入程序后,检查文件是否存在.(我可以做)

第2步:我要求用户提供要分析的文档表xls的名称.这就是它停止的地方.该程序没有检测到可用的床单:(

#check if the document exist
while True:
    x = input("Give the name of the document in this repository__")
    input_filename = x + ".xls"
    if os.path.isfile(input_filename):
        print ("the document is been charged")
        break
    else:
        print("xls not found !")

#Load the document
xls_file = pd.ExcelFile(input_filename)

#Select the good sheet in file
print ("this is your sheets in this document",xls_file.sheet_names)
while True:
    feuilles = input("Select yout sheet")
    input_feuilles = feuilles
    if xls_file.sheet_names(input_filename):
        print ("The sheet is been charged !")
        break …
Run Code Online (Sandbox Code Playgroud)

python xls

5
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×1

xls ×1