[Tutor] help for the code debug
Sailormoon
sccdzt at foxmail.com
Mon Oct 5 02:28:40 EDT 2020
Dear sir :
When I run The code as below it showed error that SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers,The excel data is like this as below screenshot .Is there anyone could help ,thanks a lot.
#导入模块
#!/usr/bin/env python
# -*- coding: utf-8 -*- #识别中文
import os
import shutil
import xlrd
#指定文件路径
path_file=r'G:\材料报验\Before 2018.12.22'
#便遍历文件夹中所有文件,此处以ls来表示,常用file
ls = os.listdir(path_file)
print(len(ls))
data = xlrd.open_workbook(r'C:\Users\Administrator\Desktop\searching.xls') # 打开xls文件
table = data.sheets()[0] # 打开第一张表
nrows = table.nrows # 获取表的行数
#datalist用来存放数据
datalist_NAME=[]
#将table中第一列的数据读取并添加到data_list中
str(datalist_NAME.extend(table.col_values(0)))
print(eval(datalist_NAME[1]) )#eval用于去除单引号,[1]指读取第二行元素
for num in range(1,nrows): #num从1到nrows遍历
for i in ls:
#利用模糊搜索find查找想要的文件
if i.find(eval(datalist_NAME[num])+"_Boundary_Line")!=-1:
shutil.copyfile(path_file+'/'+i,"F:/budyko_ds/"+i)
#shutil.move(path_file+'/'+i,"F:/budyko_ds/"+i) #直接将文件移动过去
print( datalist_NAME[num])
print( num)
print ("ALL DONE")
More information about the Tutor
mailing list