2006年09月21日 星期四 08:54
我是初学者,对于python的文件读写只知道一点点 请教:如何用python读写一定格式的数据文件? 1、FOr 循环 + writeline( ) 写出来却发现错行: For i in reange(2): j=i+1 logfile. writeline("+"+str(,j) ) ==需要: + 1 + 2 + 3 输出文件结果确是: + 1 + 2 + 3 2、限定每行128个字符还是不行,为什么啊? 2006/9/20, python-chinese-request at lists.python.cn <python-chinese-request at lists.python.cn>: > 想在 python-chinese 邮件列表发言,请写信给: > python-chinese at lists.python.cn > > 要订阅或者退订列表,可以访问万维网地址: > http://python.cn/mailman/listinfo/python-chinese > 或者可以向: > python-chinese-request at lists.python.cn > 发送主题或者正文为'help'的邮件。 > > 您可以通过邮件地址: > python-chinese-owner at lists.python.cn > 联系到此列表的管理员。 > > 当回信时,请给一个适当的标题,这样会比 "Re: > Contents of python-chinese digest..."更清楚明白。 > > > 本日主题: > > 1. Re: python 2.5发布了,嘿嘿 (linuxbbs) > 2. Re: [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > (Tom) > 3. Re: python 2.5发布了,嘿嘿 (limodou) > 4. [ot]非python--请指点js的展开效果 ( 风向标 ) > 5. Re: [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > (lazz) > 6. Re: [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > (Tom) > 7. Fwd: [CPUG::879] > [会课]提前到本周进行,CPUG/啄木鸟 第11次! (limodou) > 8. Re: [BPUG::243] 答复: [BPUG::242] > [会课]提前到本周进行,CPUG/啄木鸟 第11次! (limodou) > 9. Re: [ot]非python--请指点js的展开效果 (Yingbo Qiu) > 10. Re: 问问python虚拟机 ( 于业平 ) > 11. Re: [ot]非python--请指点js的展开效果 (yrh) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 20 Sep 2006 16:11:38 +0800 > From: "linuxbbs" <linuxbbs at 163.com> > Subject: Re: [python-chinese] python 2.5发布了,嘿嘿 > To: "python-chinese at lists.python.cn" <python-chinese at lists.python.cn> > Message-ID: <200609201611347039620 at 163.com> > Content-Type: text/plain; charset="gb2312" > > 都�签跌�Yr�钆鹅�:虞��z��戴m5�4����薇�槽)守h�����)薇��'��{b�从��k伸\z���*r�'r��⑺lzwi守h�b��-�����殊m��.n������)薇贽��X���'ru'叉��z千v殪够�薅��'r�谦z�操b槽)守h��症�撷m�槭���ē��+-�棹���)薇嵊0�.m�槭���*^����'r�强j�r���:虞待��}埚���碛M5�� > > ------------------------------ > > Message: 2 > Date: Wed, 20 Sep 2006 16:12:33 +0800 > From: Tom <zysno1 at gmail.com> > Subject: Re: [python-chinese] [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > To: python-chinese at lists.python.cn > Message-ID: <4510F7F1.905 at gmail.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > lazz 写道: > > 哦 > > 原来是这样 > > > > 但是那个三角太不明显了 > > 而且旁边的汉字很大块,鼠标一移过去看到有pop > > 我就以为应该是汉字弹出来的 > > 但是却怎么也点不中.... > > > > 现在知道了 > > 不过还是觉得点一个三角有点麻烦 > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > 不用点。鼠标移到三角上就可以。:)如果是移到菜单上就弹出,那样也很不爽。 > 会感觉经常弹出菜单。我们刚开始是这样做的。有很多用户觉得不好,才改成 > flickr式的。然后又改成现在这样的。 > > > ------------------------------ > > Message: 3 > Date: Wed, 20 Sep 2006 16:18:45 +0800 > From: limodou <limodou at gmail.com> > Subject: Re: [python-chinese] python 2.5发布了,嘿嘿 > To: python-chinese at lists.python.cn > Message-ID: > <505f13c0609200118j6e0127a3kc6830a5995eae79d at mail.gmail.com> > Content-Type: text/plain; charset=GB2312; format=flowed > > On 9/20/06, linuxbbs <linuxbbs at 163.com> wrote: > > > > > > try-except-finally以前就有啊,我还用过类 > > > > > 以前是不能同时使用,现在可以了。你再读一下文档吧,看一看有什么区别。 > > -- > I like python! > My Blog: http://www.donews.net/limodou > UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad > UliPad Maillist: http://groups.google.com/group/ulipad > > ------------------------------ > > Message: 4 > Date: Wed, 20 Sep 2006 16:22:26 +0800 > From: " 风向标 " <vaneoooo at gmail.com> > Subject: [python-chinese] [ot]非python--请指点js的展开效果 > To: python-chinese at lists.python.cn > Message-ID: > <843abbd30609200122y5ad4fdcr74bbca815494d681 at mail.gmail.com> > Content-Type: text/plain; charset="gb2312" > > 有个栏目,点进去以后有约20多个大类 > 每个大类打开又是约10-20个小类 > > 我想把所有类都在一个页面展示,减少用户查找、刷新和多次点击,提高易用性 > > 可是如果全部这样都展示出来,显得太凌乱和拥挤 > > 因此打算展示20个大类名,当点击大类名时,js代码展开子类。再点击又收回。 > > 类似这样的效果:http://www.tudou.com/help/help_index.php (下面的帮助项) > > 寻找过一些js代码,可是大多有些不够简洁,自己还不会javascript,马上学只为解决一个问题成本又太高。 > > 冒着挨骂跑题的风险在python maillist中问一下,望解惑 > > 谢谢 打扰了。 > -------------- 涓���ㄥ� -------------- > 一个HTML附件被移除... > URL: http://python.cn/pipermail/python-chinese/attachments/20060920/d9d6ab30/attachment.html > > ------------------------------ > > Message: 5 > Date: Wed, 20 Sep 2006 16:36:57 +0800 > From: lazz <lazycoding at gmail.com> > Subject: Re: [python-chinese] [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > To: python-chinese at lists.python.cn > Message-ID: > <a321204f0609200136l19a604afmc27dd6cd02c592fb at mail.gmail.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > 赫赫,众口难调~ > 建议三角至少占的面积更大些吧 > > ------------------------------ > > Message: 6 > Date: Wed, 20 Sep 2006 16:38:53 +0800 > From: Tom <zysno1 at gmail.com> > Subject: Re: [python-chinese] [OT 非PYTHON话题] > 请网通的朋友帮忙测试一下网站的速度。非常感谢 > To: python-chinese at lists.python.cn > Message-ID: <4510FE1D.6010506 at gmail.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > lazz 写道: > > 赫赫,众口难调~ > > 建议三角至少占的面积更大些吧 > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > 赫赫。那样还不如去掉三角呢。。赫赫。 > > > ------------------------------ > > Message: 7 > Date: Wed, 20 Sep 2006 17:10:22 +0800 > From: limodou <limodou at gmail.com> > Subject: [python-chinese] Fwd: [CPUG::879] > [会课]提前到本周进行,CPUG/啄木鸟 第11次! > To: " python-chinese列表 " <python-chinese at lists.python.cn> > Message-ID: > <505f13c0609200210v28f15a8buc80fd747059458e5 at mail.gmail.com> > Content-Type: text/plain; charset=GB2312; format=flowed > > ---------- Forwarded message ---------- > From: Zoom. Quiet <zoom.quiet at gmail.com> > Date: Sep 20, 2006 5:04 PM > Subject: [CPUG::879] [会课]提前到本周进行,CPUG/啄木鸟 第11次! > To: "CPUG.org mailist" <CPUG at googlegroups.com>, bpug at googlegroups.com, > "Python.cn at google" <python-cn at googlegroups.com> > > > 考虑到10.1 都有计划,提前会课到本周六 14:00~16:00 进行, > 本次回到海淀海淀区进行, 会课专页: > http://wiki.woodpecker.org.cn/moin/BPUG/2006-09-23 > > 想参加的,请在报名页面注明: > http://wiki.woodpecker.org.cn/moin/CPUGer-060923 > > 本次主题除了保留的Ubuntu 分享外, > 是Limodou 的 UliPad 项目进展汇报! > > 其它,议题,请大家主动提出,好象上次 icebird 有关Blande 有想分享的说………… > > > > -- > I like python! > My Blog: http://www.donews.net/limodou > UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad > UliPad Maillist: http://groups.google.com/group/ulipad > > ------------------------------ > > Message: 8 > Date: Wed, 20 Sep 2006 17:21:06 +0800 > From: limodou <limodou at gmail.com> > Subject: Re: [python-chinese] [BPUG::243] 答复: [BPUG::242] > [会课]提前到本周进行,CPUG/啄木鸟 第11次! > To: bpug at googlegroups.com, "Python.cn at google" > <python-cn at googlegroups.com>, " python-chinese列表 " > <python-chinese at lists.python.cn>, CPUG at googlegroups.com > Message-ID: > <505f13c0609200221t484fc518o1b91a8987b53664e at mail.gmail.com> > Content-Type: text/plain; charset=GB2312; format=flowed > > On 9/20/06, aBBISh <ops.tong at gmail.com> wrote: > > 请问这样的会课主要是干什么的?任何人都可以参加么? > > > 让大家有一个交流的机会,任何人可以预定发言的主题同大家交流。任何人可以参加。时间和地方已经公布了。 > > -- > I like python! > My Blog: http://www.donews.net/limodou > UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad > UliPad Maillist: http://groups.google.com/group/ulipad > > ------------------------------ > > Message: 9 > Date: Wed, 20 Sep 2006 17:26:39 +0800 > From: "Yingbo Qiu" <qiuyingbo at gmail.com> > Subject: Re: [python-chinese] > [ot]非python--请指点js的展开效果 > To: python-chinese at lists.python.cn > Message-ID: > <fd038ca40609200226t2f2e027dx7f95c9730ee28f95 at mail.gmail.com> > Content-Type: text/plain; charset=GB2312; format=flowed > > 传说 JQuery 不错,有个只懂 xHTML/CSS 的朋友,说这个东西很好 > > ------------------------------ > > Message: 10 > Date: Wed, 20 Sep 2006 18:35:25 +0800 > From: " 于业平 " <yyp226 at gmail.com> > Subject: Re: [python-chinese] 问问python虚拟机 > To: python-chinese at lists.python.cn > Message-ID: > <1f6d41170609200335m5eee054ex155038d6a03c0c89 at mail.gmail.com> > Content-Type: text/plain; charset="gb2312" > > 我是想问python能不能在dos(系统)下跑(Run) > 不用回答了 , 我已经找到了: > http://www.caddit.net/pythond.php > PythonD is a 32-bit, multi-threaded, networking- and OpenGL-enabled Python > interpreter for DOS and Windows. > -------------- 涓���ㄥ� -------------- > 一个HTML附件被移除... > URL: http://python.cn/pipermail/python-chinese/attachments/20060920/57b8058e/attachment.htm > > ------------------------------ > > Message: 11 > Date: Wed, 20 Sep 2006 20:57:00 +0800 > From: yrh <yuanruihong at 126.com> > Subject: Re: [python-chinese] > [ot]非python--请指点js的展开效果 > To: python-chinese at lists.python.cn > Message-ID: <45113A9C.1080509 at 126.com> > Content-Type: text/plain; charset=GB2312 > > 我记得动网好像有个树形菜单,用JavaScript和css来控制的,很简洁,你google > 一下就是了。 > 网上有很多类似你邮件里的菜单,你上网搜搜,好像一般叫它作"QQ菜单",好像有 > 很多。 > > > 风向标 写道: > > 有个栏目,点进去以后有约20多个大类 > > 每个大类打开又是约10-20个小类 > > 我想把所有类都在一个页面展示,减少用户查找、刷新和多次点击,提高易用性 > > 可是如果全部这样都展示出来,显得太凌乱和拥挤 > > 因此打算展示20个大类名,当点击大类名时,js代码展开子类。再点击又收回。 > > 类似这样的效果:http://www.tudou.com/help/help_index.php (下面的帮助项) > > 寻找过一些js代码,可是大多有些不够简洁,自己还不会javascript,马上学只 > > 为解决一个问题成本又太高。 > > 冒着挨骂跑题的风险在python maillist中问一下,望解惑 > > 谢谢 打扰了。 > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese at lists.python.cn > > Subscribe: send subscribe to python-chinese-request at lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request at lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > ------------------------------ > > _______________________________________________ > python-chinese mailing list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > 结束python-chinese 摘要, 卷 33, 发布 150 > *********************************************** >
2006年09月21日 星期四 09:06
On 9/21/06, Xuefei <zhangxuefei在gmail.com> wrote: > 我是初学者,对于python的文件读写只知道一点点 > 请教:如何用python读写一定格式的数据文件? > 1、FOr 循环 + writeline( ) 写出来却发现错行: > For i in reange(2): > j=i+1 > logfile. writeline("+"+str(,j) ) > ==需要: + 1 > + 2 > + 3 > 输出文件结果确是: > + > 1 + > 2 + > 3 > 2、限定每行128个字符还是不行,为什么啊? > > 建议如下: 1. 对于新问题,请新开一个主题,不要在某一个邮件的后面回复 2. 回复时,尽量将无用的东西去掉 3. 提问时,请把问题相关的内容描述清楚,如logfile是一个什么东西,一般的file对象是没有writeline()这个方法的。而且希望把代码写正确。是ranage,不是reange。而且你的循环次次也根本不对,不知道你的结果是如何得出来的。是for不是FOr或For,python识别大小写。这些细节请注意。 4. 不知道详细的信息,所以无法给你回答,建议你先不要写文件,使用print语句打印看一下结果,多做些测试。 -- I like python! My Blog: http://www.donews.net/limodou UliPad Site: http://wiki.woodpecker.org.cn/moin/UliPad UliPad Maillist: http://groups.google.com/group/ulipad
2006年09月21日 星期四 19:09
2006/9/21, limodou <limodou at gmail.com>: > > > 建议如下: > > 1. 对于新问题,请新开一个主题,不要在某一个邮件的后面回复 > 2. 回复时,尽量将无用的东西去掉 > 3. > 提问时,请把问题相关的内容描述清楚,如logfile是一个什么东西,一般的file对象是没有writeline()这个方法的。而且希望把代码写正确。 > 是ranage,不是reange。 > 而且你的循环次次也根本不对,不知道你的结果是如何得出来的。是for不是FOr或For,python识别大小写。这些细节请注意。 > 4. 不知道详细的信息,所以无法给你回答,建议你先不要写文件,使用print语句打印看一下结果,多做些测试。 呵呵,limodou也被影响了。 -- I like Python & Linux. Blog: http://recordus.cublog.cn -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20060921/95e819cf/attachment.html
Zeuux © 2025
京ICP备05028076号