【发布时间】:2022-08-05 23:34:14
【问题描述】:
示例环境
import os
import shutil
for filenames in os.getcwd():
if filename.contains (\'pig\'):
os.mkdir(\'Pig\')
#move all the filenames which contain the name pig in it
shutil.copy(filename-with-pig, Pig)
if if filename.contains (\'dog\'):
os.mkdir(\'Dog\')
#move all the filenames which contain the name Dog in it
shutil.copy(filename-with-dog, Dog)
如何在 Python 中做到这一点? 我已经尝试了一点,但是有很多错误
-
这通常应该有效(尽管其中一些显然是伪代码,而不是实际代码)。如果您遇到错误,请发布它们。
标签: python python-3.x file operating-system shutil