用python读取带密码的excel文件中的数据

用python读取带密码的excel文件中的数据,程序代码如下:
 
#filename:readingxls.py
'''
此程序的作用为:用python读取带密码的excel文件中的数据。
首先通过pip安装xlrd第三方库 pip3 install xlrd
请输入excel文件路径:D:\x1.xls
'''
import xlrd
path=input("请输入excel文件路径:")
workbook=xlrd.open_workbook(path)
b=len(workbook.sheets())
i=0
for i in range(b):
    sheet=workbook.sheet_by_index(i)
    for row in range(sheet.nrows):
        print()
        for col in range(sheet.ncols):
            print("%7s"%sheet.row(row)[col].value,'\t',end='')
print()

猜你喜欢

转载自www.cnblogs.com/zhn620/p/9251169.html