📜  重命名文件夹中带有空格的文件python代码示例

📅  最后修改于: 2022-03-11 14:45:13.349000             🧑  作者: Mango

代码示例1
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> path  = os.getcwd()
>>> filenames = os.listdir(path)
>>> for filename in filenames:
...     os.rename(os.path.join(path, filename), os.path.join(path, filename.replace(' ', '-')))
...
>>>