import os
import csv
def readFile(pathFile):
fileList = os.listdir(pathFile)
for file in fileList:
#路径转换为正常路径
domain = os.path.abspath(pathFile)
path = os.path.join(domain, file)
with open(path, 'r', encoding='utf-8') as f:
readData = csv.reader(f)
result = list(readData)
for row in result:
print(row)
if __name__ == '__main__':
#文件路径单‘\’会报错
pathFile = 'D:\\user\\ddf\csvfile'
readFile(pathFile)
网友评论