加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
遍历文件夹_取文件路径.py 902 Bytes
一键复制 编辑 原始数据 按行查看 历史
fengmingshan 提交于 2021-12-15 20:46 . 找回资料提交
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 9 19:29:39 2018
@author: Administrator
"""
import os
import pandas as pd
import math
pic_path = r'f:\资源照片一站一档'+'\\'
out_path = r'd:\test'+'\\'
pic_list = []
for root, dirs, files in os.walk(pic_path):
for name in files:
pic_list.append(os.path.join(root, name))
for i in range(0,math.ceil(len(pic_list)/10000),1):
with open(out_path + '图片列表' + str(i) + '.csv' ,'w') as writer:
df_out = pd.DataFrame()
df_out['pic_path'] = ''
if (i+1)*10000 < len(pic_list):
for j in range(i*10000,(i+1)*10000,1):
df_out.loc[j,'pic_path'] = pic_list[j]
df_out.to_csv(writer)
if (i+1)*10000 > len(pic_list):
for j in range(i*10000,len(pic_list),1):
df_out.loc[j,'pic_path'] = pic_list[j]
df_out.to_csv(writer)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化