select_video_path = "/root/web/source/select_video/" videos = os.listdir(select_video_path) for video in videos: video_name = os.path.join("select_video/",video) break copyfile("/root/web/source/"+video_name,"/root/web/source/now_video/"+ video) copyfile("/root/web/source/bing1_1.MP4", "/root/web/source/input_har.mp4") return_state = 200把这段代码改写成输出读取选择视频中的全部视频并输出
时间: 2023-09-15 22:21:33 浏览: 91
os.rar_fat_os 文件系统
可以将代码改为以下形式:
```
import shutil
select_video_path = "/root/web/source/select_video/"
videos = os.listdir(select_video_path)
for video in videos:
video_path = os.path.join(select_video_path, video)
shutil.copy(video_path, "/root/web/source/now_video/" + video)
print("Copied", video_path, "to", "/root/web/source/now_video/" + video)
shutil.copy("/root/web/source/bing1_1.MP4", "/root/web/source/input_har.mp4")
print("Copied /root/web/source/bing1_1.MP4 to /root/web/source/input_har.mp4")
return_state = 200
```
这样,每次循环时就会输出一个视频的路径,并将其复制到目标路径。同时也会输出 MP4 文件的复制过程。
阅读全文