2006年01月20日 星期五 15:02
Skipped content of type multipart/alternative-------------- next part -------------- A non-text attachment was scrubbed... Name: wangzhe.vcf Type: text/x-vcard Size: 304 bytes Desc: not available Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20060120/fa17da5a/wangzhe-0001.vcf
2006年01月20日 星期五 15:37
郁闷,我加上之后,一双击就提示 Python出错,是不是加错位置了?
# -*- coding: cp936 -*-
from Tkinter import *
wnd = Tk()
wnd.btn = Button(wnd,text="shai")
wnd.btn.pack(side=LEFT)
def shai():
import tkFileDialog
a=tkFileDialog.askopenfilename()
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)
wnd.mainloop()
wy4948
2006-01-20
发件人: wangzhe
发送时间: 2006-01-20 15:29:49
收件人: python-chinese at lists.python.cn
抄送:
主题: Re: Spam: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
指定编码为cp936
======== 2006-01-20 14:50:06 您在来信中写道: ========
我的问题就是不用Tkinter 设置“我爱你”为关键字,可以搜出来
用了Tkinter之后就搜不出来了。
我给你个txt吧
a
我爱你么
b
我爱
c
我爱你我爱你
功能就是生成一个txt里面包含
a
c
wy4948
2006-01-20
发件人: wangzhe
发送时间: 2006-01-20 14:47:46
收件人: wy4948
抄送:
主题: Re: Re: Re: Re: Re: Re: Re: Re: Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
你要包含这个关键字啊!?这不是调用Tkinter的问题,处理含数没有处理。
======== 2006-01-20 14:35:11 您在来信中写道: ========
我汗!
那个代码不是写在那里了,就是从一个txt文件中,搜索出包含关键字“我爱你”,然后把包含这个关键字的上一行写到一个新txt文件中。
我不使用Tkinter
import tkFileDialog
a=tkFileDialog.askopenfilename()
f=open(a)
f1=open("result.txt","w+")
s=f.readlines()
for i in range(1,len(s)):
if "我爱你" in s[i] and len(s[i-1]) > 12:
f1.write(s[i-1])
f.close()
f1.close()
已经实现了
但
加上Tkinter之后,就不能筛选 中文了。只能筛选 英文的
wy4948
2006-01-20
发件人: wangzhe
发送时间: 2006-01-20 14:32:43
收件人: wy4948; python-chinese at lists.python.cn
抄送:
主题: Re: Re: Re: Re: Re: Re: Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
“中文所需要查找的关键字”?我是看不懂,能不能把需求说的明确点呢?你是要找中文文件中的内容么?找到了关键字又想干什么呢?说清楚好!!
======== 2006-01-20 14:19:24 您在来信中写道: ========
还要麻烦下大家,这个里面怎么修改才能支持 中文做需要查找的关键字啊?
wy4948
2006-01-20
发件人: wangzhe
发送时间: 2006-01-20 12:27:28
收件人: wy4948; python-chinese at lists.python.cn
抄送:
主题: Re: Re: Re: Re: Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
其它的TXT文件也没问题呢,你的是什么文件啊?你要找什么内容呢?
======== 2006-01-20 11:22:49 您在来信中写道: ========
晕,果然呢,但我选择其他的txt文件就不行了,奇怪死了,弄了半天都弄不好,能帮我看看不?
-----原始邮件-----
发件人:"wangzhe"
发送时间:2006-01-20 11:09:17
收件人:"wy4948" ,"python-chinese at lists.python.cn"
抄送:(无)
主题:Re: Re: Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
不好意思没有说清楚,运行的时候不是要选择文件麽?反正就是由关键字的文件,我选择了运行文件自己。生成的新文件是有内容的。和代码内容相符合。
======== 2006-01-20 10:52:21 您在来信中写道: ========
怎么运行时选择运行文件本身的?
我直接双击运行的呢?
不好意思,上周才开始接触python
-----原始邮件-----
发件人:"wangzhe"
发送时间:2006-01-20 10:10:59
收件人:"python-chinese at lists.python.cn"
抄送:(无)
主题:Re: [python-chinese] Tkinter按钮调用函数怎么出错了?
运行时选择运行文件本身,我这里使用生成的文件不是0K啊!哪里有问题呢?
代码如下:
不使用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()
= = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = =
想 要 一 个 快 n 倍 的 免 费 邮 箱 吗 ?
126 专 业 电 子 邮 局 ―― 全 球 领 先 的 中 文 邮 箱 带 你 进 入 极 速 之 旅
= = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = =
= = = = = = = = = = = = = = = = = = = = = =
致
礼!
wangzhe
wangzhe at eastcom.com
2006-01-20
= = = = = = = = = = = = = = = = = = = = = =
致
礼!
wangzhe
wangzhe at eastcom.com
2006-01-20
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060120/5071706e/attachment.html
Zeuux © 2025
京ICP备05028076号