窗口程序的源码为:
###create a window to support search function
root.mainloop()
其中pathschversion001 源码为:
#from time import *
import time
import os
"""
sfilename = input("Please input search filename :")
stimebg = input("Please input search time begin :")
stimend = input("Please input search time end :")
spath = input("Please input search on path :")
"""
fileres = []
ctime = time.strftime("%Y%m%d",time.localtime(time.time()))
def search(sfilename,stimebg,stimend,spath):
#global ctime
if(stimend[0] == '0'):
stimend = ctime
###print("search time end change for :",stimend)
#get curent time
curtime = ctime
print("Curent time is :",curtime)
#print(spath)
os.chdir(spath)
curpath = os.getcwd()
print("You search path is :",os.getcwd())
#save file searched in list
global fileres
listfile = os.listdir(spath)
oldspath = spath
#print('88listfile is :',listfile)
for lfile in listfile:
os.chdir(spath)
tspath = curpath
dirup = tspath+os.sep+lfile
if(os.path.isfile(dirup)):
###print(lfile+': is a file')
tsfiletime = time.strftime("%Y%m%d",time.localtime(os.path.getctime(dirup)))
###print(lfile+": create time is :",tsfiletime)
if(lfile.find(sfilename)!= -1 and tsfiletime >stimebg and tsfiletime <= stimend):
###print("search file ok :",tspath+"\\"+lfile)
fileres.append(tspath+"\\"+lfile)
elif(os.path.isdir(dirup)):
###print(lfile+' is a dir')
search(sfilename,stimebg,stimend,dirup)
else:
###print(lfile+' I dont know This Type or ')
pass
"""
print("search result is :")
for file in fileres:
print("file :",file)
"""
#return fileres
"""
if __name__ =='__main__':
file = search(sfilename,stimebg,stimend,spath)
print(file)
"""
上述实现只是为了娱乐,重在了解python的基本操作
对于python的脚本发布,可以通过如下源码实现可以放入叫setup.py文件中:
from distutils.core import setup
import py2exe
setup(console=['pathschversion002.py'])
只需要在cmd中执行setup.py py2exe即可生成发布的可执行文件了(注:这儿需要安装py2exe哦!)