python 按列读取txt 及文件夹下文件名

f = open('./data.txt','r')
lines = f.readlines()
f.close()
for line in lines:
    username = line.split(',')[0] #按逗号分隔符提取
    password = line.split(',')[1]
    #print(username)
    print(password)
#读取文件夹下文件名
inpath = "./"
#uipath = unicode(inpath, "utf8")
uipath = str(inpath)
for path,dir,filelist in os.walk(uipath):
    for filename in filelist:
        allfile.append(os.path.join(path,filename))

 

你可能感兴趣的:(Python)