python-问题记录
2020-12-01 本文已影响0人
笑破天
1、python读取excel
def read_xlrd(excelFile):
data = xlrd.open_workbook(excelFile)
table = data.sheet_by_index(0)
dataFile = []
for rowNum in range(141,196):
url = str(table.cell(rowNum, 3).value)
if len(url) > 5:
urlArr = spRow0(url)
rowArr = [urlArr[0],urlArr[1],table.cell(rowNum,5).value]
dataFile.append(rowArr)
return dataFile
rows = read_xlrd('/Users/xxx/Desktop/test.xlsx')
print('行数:' + str(len(rows)))
print(rows)
2、python遍历目录下所有子层级的文件
for root,dirs,files in os.walk(rootDir):
for file in files:
print(os.path.join(root,file))
for dir in dirs:
print(os.path.join(root, dir))
3、安装PIL报错
pip3 install pillow