current_path = os.path.dirname(__file__)pre_path = os.path.dirname(current_path)images_path = os.path.join(pre_path,'images') # 如果目录不存在,创建目录
if not os.path.exists(images_path):
os.mkdir(images_path)
else:
print('目录已存在...')src – 要修改的目录名 dst – 修改后的目录名
os.rename(src, dst)参数src - 原来的文件全路径(含文件名) dst - 修改后的文件全路径(含文件名)
shutil.move(src, dst)参见:https://blog.csdn.net/qq_38640439/article/details/81410116