擅长:python、mysql、java
<p>我猜您使用的是<code>Python3</code>,因为这是<code>Python2</code>中的有效语法。对于<code>Python3</code>,请使用以下内容:</p>
<pre><code>import os
def rename_file():
file_list = os.listdir(r"C:\Users\Sushant\Desktop\test")
print(file_list)
for file_name in file_list:
os.rename(file_name, file_name.translate(str.maketrans("", "", "0123456789")))
rename_file()
</code></pre>
<p>这是<a href="https://docs.python.org/3/library/stdtypes.html#str.maketrans" rel="nofollow noreferrer">maketrans</a>函数的文档。在</p>