<p>我不熟悉Python编码,所以这里有个问题。我想找到任何扩展名为“无标题”的文件,例如jpg,indd,psd。然后将它们重命名为当天的日期。在</p>
<p>我试过以下方法:</p>
<pre><code>import os
for file in os.listdir("/Users/shirin/Desktop/Artez"):
if file.endswith("untitled.*"):
print(file)
</code></pre>
<p>当我运行脚本时,什么都没有发生。在</p>
<p>Python字符串比较器不支持通配符。您可以在文本中的任何位置搜索“untitled.”:</p>
<pre><code>import os
for file in os.listdir("/Users/shirin/Desktop/Artez"):
if "untitled." in file:
print(file)
</code></pre>
<p>请记住,这将包括在文件的任何位置有“untitled.”的任何文件。在</p>