【发布时间】:2019-04-02 07:13:21
【问题描述】:
我正在尝试重命名文件夹中的多个文件,以便删除每个字母,但运行时出现此错误:
FileNotFoundError: [WinError 2] 系统找不到文件 指定:'Amsterdam1971' -> '1971'
import os
os.chdir(directory)
for f in os.listdir():
f_name, f_ext = os.path.splitext(f)
os.rename(f_name,f_name.translate(str.maketrans("","","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")))
【问题讨论】:
标签: python-3.x