我有一行脚本,它抓取目录和子目录中的所有 .blend 文件并将它们的路径写入文件。我希望每一行都有一个起始前缀”但它不起作用。当我在我也需要的行尾添加前缀时,它会起作用。for root, dirs, files in os.walk(cwd): for file in files: if file.endswith('.blend'): with open("filepaths","a+") as f: f.write(os.path.join('"', root, file, '",' "\n"))这输出/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/splash279.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/lib/props/barbershop_pole.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/lib/props/hairdryer.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/lib/chars/pigeon.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/lib/chars/agent.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/lib/nodes/nodes_shaders.blend/",/home/django/copypaste/cleanup/var/media/admin/94bbcd25-10a2-4ec2-bd83-a7cef0690320/splash279/tools/camera_rig.blend/",但它缺少"行开头的第一个前缀
添加回答
举报
0/150
提交
取消