python3.4批量重命名程序封装

来源:互联网 发布:java axis简单入门 编辑:程序博客网 时间:2024/06/03 15:14

出于工作需要写了一个批量重命名的程序,然后试着封装成winexe文件。


import osprint("Welcome to use this program")print("*"*20)#执行重命名功能path = ''path=input("Please input path: ")old=""new=""old=input("Please input the old filename (only part of it is also accepted): ")new=input("Please input the new filename: ")for file in os.listdir(path):    if os.path.isfile(os.path.join(path,file))==True:        newname = file.replace(old,new)        os.rename(os.path.join(path,file),os.path.join(path,newname))#打印重命名后的文件名列表        for file in os.listdir(path):    if os.path.isfile(os.path.join(path,file))==True:        print(file)        print("Succeed")



上午刚好复习了一下input输入,正好用上。

听说pyinstaller封装不错,于是也刚好试了一下。最一开始提示说有错误,原来是缺少一个piwin32组件。去官网下载后再次用cmd运行,然而还是缺少组件。又查找资料把dll文件添加进系统的path环境,最终成功封装。pyinstaller还是需要更多了解

1 0
原创粉丝点击