2007年06月29日 星期五 20:46
f = open(...) lines = f.readlines() lines.insert(line_no, "anything you want") ... 在 07-6-29,pt42<pt4200在gmail.com> 写道: > 你好: > > 有没有增强的文件处理模块可以实现插入的操作? > > 比如:文件内容是 > aaa > bbb > > 插入一段字符串ccc后,文件的内容为 > aaa > ccc > bbb > > 在文件大小为1M以上的情况下,如何实现这个操作?谢谢 > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to > python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request在lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese >
2007年06月29日 星期五 21:04
f = open("file", "r+) f.seek(3,0) f.write("bbb") f.close() ÔÚ07-6-29£¬Can Xue <xuecan在gmail.com> дµÀ£º > > f = open(...) > lines = f.readlines() > lines.insert(line_no, "anything you want") > ... > > ÔÚ 07-6-29£¬pt42<pt4200在gmail.com> дµÀ£º > > ÄãºÃ£º > > > > ÓÐûÓÐÔöÇ¿µÄÎļþ´¦ÀíÄ£¿é¿ÉÒÔʵÏÖ²åÈëµÄ²Ù×÷£¿ > > > > ±ÈÈ磺ÎļþÄÚÈÝÊÇ > > aaa > > bbb > > > > ²åÈëÒ»¶Î×Ö·û´®cccºó£¬ÎļþµÄÄÚÈÝΪ > > aaa > > ccc > > bbb > > > > ÔÚÎļþ´óСΪ1MÒÔÉϵÄÇé¿öÏ£¬ÈçºÎʵÏÖÕâ¸ö²Ù×÷£¿Ð»Ð» > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070629/628b36b7/attachment.htm
2007年06月30日 星期六 19:15
»á¸²¸ÇºóÐøµÄ×Ö·û Îļþ»á±ä³Éaaabbbcc ÔÚ07-6-29£¬³È×Ó <eyeonme在gmail.com> дµÀ£º > > f = open("file", "r+) > f.seek(3,0) > f.write("bbb") > f.close() > > ÔÚ07-6-29£¬Can Xue <xuecan在gmail.com > дµÀ£º > > > > f = open(...) > > lines = f.readlines() > > lines.insert(line_no, "anything you want") > > ... > > > > ÔÚ 07-6-29£¬pt42<pt4200在gmail.com> дµÀ£º > > > ÄãºÃ£º > > > > > > ÓÐûÓÐÔöÇ¿µÄÎļþ´¦ÀíÄ£¿é¿ÉÒÔʵÏÖ²åÈëµÄ²Ù×÷£¿ > > > > > > ±ÈÈ磺ÎļþÄÚÈÝÊÇ > > > aaa > > > bbb > > > > > > ²åÈëÒ»¶Î×Ö·û´®cccºó£¬ÎļþµÄÄÚÈÝΪ > > > aaa > > > ccc > > > bbb > > > > > > ÔÚÎļþ´óСΪ1MÒÔÉϵÄÇé¿öÏ£¬ÈçºÎʵÏÖÕâ¸ö²Ù×÷£¿Ð»Ð» > > > _______________________________________________ > > > python-chinese > > > Post: send python-chinese在lists.python.cn > > > Subscribe: send subscribe to > > > python-chinese-request在lists.python.cn > > > Unsubscribe: send unsubscribe to > > > python-chinese-request在lists.python.cn > > > Detail Info: > > > http://python.cn/mailman/listinfo/python-chinese > > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese > -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070630/0abb66d7/attachment.html
2007年06月30日 星期六 19:16
ÕâÖÖ·½·¨Ò²Êǽ«Îļþ¶ÁÈëÄÚ´æºó£¬ÔÙдÈëÎļþ ЧÂʲ»¸ß ÔÚ07-6-29£¬Can Xue <xuecan在gmail.com> дµÀ£º > > f = open(...) > lines = f.readlines() > lines.insert(line_no, "anything you want") > ... > > ÔÚ 07-6-29£¬pt42<pt4200在gmail.com> дµÀ£º > > ÄãºÃ£º > > > > ÓÐûÓÐÔöÇ¿µÄÎļþ´¦ÀíÄ£¿é¿ÉÒÔʵÏÖ²åÈëµÄ²Ù×÷£¿ > > > > ±ÈÈ磺ÎļþÄÚÈÝÊÇ > > aaa > > bbb > > > > ²åÈëÒ»¶Î×Ö·û´®cccºó£¬ÎļþµÄÄÚÈÝΪ > > aaa > > ccc > > bbb > > > > ÔÚÎļþ´óСΪ1MÒÔÉϵÄÇé¿öÏ£¬ÈçºÎʵÏÖÕâ¸ö²Ù×÷£¿Ð»Ð» > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to > > python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to > > python-chinese-request在lists.python.cn > > Detail Info: > > http://python.cn/mailman/listinfo/python-chinese > > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070630/a6b46efe/attachment.html
Zeuux © 2025
京ICP备05028076号