import asyncio
import os
async def change_files(x):
files=os.listdir("D:/test")
for filename in files:
portion=os.path.splitext(filename)
print(portion)
if portion[1]==".py":
newname=portion[0]+".txt"
os.chdir("D:/test")
os.rename(filename,newname)
return '{}任务完成'.format(x)
def callback(future):
print("Callback: ",future.result())
coroutine=change_files("修改扩展名")
loop=asyncio.get_event_loop()
task=asyncio.ensure_future(coroutine)
task.add_done_callback(callback)
loop.run_until_complete(task)
批量修改文件名
最新推荐文章于 2024-11-18 20:04:00 发布