import os
 
def file_name(file_dir): 
    for root, dirs, files in os.walk(file_dir):
        print(root) #当前目录路径
        print(dirs) #当前路径下所有子目录
        print(files) #当前路径下所有非目录子文件
dir1="d:/tu1"
dir1="https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/"
#file_name(dir1)
import exrex
for i in range(5):
    aa=exrex.getone(r\'\d{1,4}\')
    print(dir1+aa+".jpg")
    i+=1

 结果:

================== RESTART: D:/Python/Python37/lian0213a.py ==================
https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/7061.jpg
https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/0.jpg
https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/20.jpg
https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/202.jpg
https://cdn.deere.com:2020/57-tuimm/uploads/allimg/2002101/0601.jpg
>>>

 

版权声明:本文为xkdn原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xkdn/p/12303603.html