Python把当前文件目录下的png/jpg/jpeg文件自动复制N张
import os
import shutil
import time
PNG = 'png'
JPG = 'jpg'
JPEG = 'jpeg'
COUNT = 5 # 复制的数量
# 获取当前文件目录下原始源文件的前缀和后缀
def get_file_info():
for root, dirs, files in os.walk(".", topdown=False):
for name in files:
if (name.endswith(PNG) or name.endswith(JPG) or name.endswith(JPEG)):
pre = name.split('.')[0]
suf = name.split('.')[1]
print('pre:' + pre + " suf:" + suf)
return name, pre, suf
if __name__ == '__main__':
fn, pre, suf = get_file_info()
for i in range(COUNT): # 复制的数量
time.sleep(0.1)
shutil.copyfile(fn, '{pre}-{i}.{suf}'.format(pre=pre, i=i, suf=suf))
Python内存映射文件读写_python 文件映射_zhangphil的博客-CSDN博客import osimport timeimport mmapfilename = 'test.txt'#如果不存在,创建。if not os.path.exists(filename): open(filename, 'w')print(os.path.isdir(filename))if os.path.isfile(filename): print(ti...
https://blog.csdn.net/zhangphil/article/details/88691321
格式化的随机行数据写入本地文件,Python_python格式化写入文件_zhangphil的博客-CSDN博客格式化的随机行数据写入本地文件,Python
https://blog.csdn.net/zhangphil/article/details/125226462
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)