2006年01月20日 星期五 10:00
代码如下:
不使用Tkinter已经可以了,但我想写个界面的,使用按钮选择,这样怎么只能生成一个0kb的文件呢?
from Tkinter import *
wnd = Tk()
wnd.btn = Button(wnd,text="shai")
wnd.btn.pack(side=LEFT)
import tkFileDialog
b=tkFileDialog.askopenfilename()
def shai(a):
f=open(a)
f1=open("result.txt","w+")
s=f.readlines()
for i in range(len(s)):
if "设置的关键字" in s[i]:
f1.write(s[i-1])
f.close()
f1.close()
wnd.btn.config(command=shai(b))
wnd.mainloop()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060120/fbb0d2ef/attachment.html
Zeuux © 2025
京ICP备05028076号