2007年01月12日 星期五 18:35
Çë½ÌÔÚÒ»¸öĿ¼ÖÐÓÐN¸öTXTÎļþ,ÏÖÔÚÐèÒª¶Ôÿ¸öTXTÀïµÄijһÏàͬ×ֶνøÐÐÌæ´ú,ÇëÎʸÃÔõô²Ù×÷? -- Thank you Kid.Jiang -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070112/bd8112cc/attachment.html
2007年01月12日 星期五 22:08
ÓÃdirµÃµ½Ä¿Â¼ÖеÄÎļþµÄÃû×Ö£¬È»ºóÓÃmap»òforÖ®ÀàµÄ¶Ôÿһ¸öÎļþ½øÐУº ¶Áµ½ÄÚ´æÖУ¬È»ºóÀûÓÃ×Ö·û´®Ìæ»»²Ù×÷Ìæ»»£¬ÔÙд»ØÈ¥ ÕâÑù¾Í¿ÉÒÔÁË°É£¬²»ÖªµÀ»¹ÓÐûÓиüºÃµÄ°ì·¨¡£ ÔÚ07-1-12£¬Kid. Jiang <kid.jiang在gmail.com> дµÀ£º > > Çë½ÌÔÚÒ»¸öĿ¼ÖÐÓÐN¸öTXTÎļþ,ÏÖÔÚÐèÒª¶Ôÿ¸öTXTÀïµÄijһÏàͬ×ֶνøÐÐÌæ´ú,ÇëÎʸÃÔõô²Ù×÷? > > -- > Thank you > > Kid.Jiang > _______________________________________________ > 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/20070112/97781b57/attachment.html
2007年01月12日 星期五 23:01
只能这样了 如果不是编程的话 是实际做的事情的话 用一个编辑工具,比如vc全部打开,全部替换吗 呵呵 这个大家都会的 On 1/12/07, Chunshi Feng <fengchunshi at gmail.com> wrote: > > 用dir得到目录中的文件的名字,然后用map或for之类的对每一个文件进行: > 读到内存中,然后利用字符串替换操作替换,再写回去 > 这样就可以了吧,不知道还有没有更好的办法。 > > > 在07-1-12,Kid. Jiang <kid.jiang at gmail.com> 写道: > > > > 请教在一个目录中有N个TXT文件,现在需要对每个TXT里的某一相同字段进行替代,请问该怎么操作? > > > > -- > > Thank you > > > > Kid.Jiang > > _______________________________________________ > > 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 > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://python.cn/pipermail/python-chinese/attachments/20070112/48eac9af/attachment.htm
2007年01月13日 星期六 13:31
用sed呀。 On Fri, 2007-01-12 at 23:01 +0800, jay wrote: > 只能这样了 > 如果不是编程的话 是实际做的事情的话 > 用一个编辑工具,比如vc全部打开,全部替换吗 > 呵呵 这个大家都会的 > > On 1/12/07, Chunshi Feng <fengchunshi在gmail.com> wrote: > 用dir得到目录中的文件的名字,然后用map或for之类的对每一个文件 > 进行: > 读到内存中,然后利用字符串替换操作替换,再写回去 > 这样就可以了吧,不知道还有没有更好的办法。 > > > 在07-1-12,Kid. Jiang <kid.jiang在gmail.com> 写道: > 请教在一个目录中有N个TXT文件,现在需要对每个TXT里的某一 > 相同字段进行替代,请问该怎么操作? > > -- > Thank you > > Kid.Jiang > _______________________________________________ > 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
2007年01月13日 星期六 14:17
import os import re for filename in os.listdir(dir): path = os.path.join(dir, filename) data = open(path, 'rb').read() newdata = re.sub("aaaa", "bbbb", data) if newdata != data: fp = open(path, 'wb') fp.write(newdata) fp.close() On 1/12/07, Kid. Jiang <kid.jiang在gmail.com> wrote: > 请教在一个目录中有N个TXT文件,现在需要对每个TXT里的某一相同字段进行替代,请问该怎么操作? > > -- > Thank you > > Kid.Jiang > _______________________________________________ > 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 > -- Best Regards, Jetrix Chan ---- jetrixc在gmail.com
2007年01月13日 星期六 17:05
רҵһµã¶ùµÄʹÓÃawk£¬ËüµÄЧÂʾÝ˵±ÈC»¹¸ß£» Ò»°ãµÄʹÓÃperl£¬python¶¼²»´í¡£ jay <ggwjgg在gmail.com> дµÀ£º Ö»ÄÜÕâÑùÁË Èç¹û²»ÊDZà³ÌµÄ»° ÊÇʵ¼Ê×öµÄÊÂÇéµÄ»° ÓÃÒ»¸ö±à¼¹¤¾ß£¬±ÈÈçvcÈ«²¿´ò¿ª£¬È«²¿Ìæ»»Âð ºÇºÇ Õâ¸ö´ó¼Ò¶¼»áµÄ On 1/12/07, Chunshi Feng <fengchunshi在gmail.com > wrote:ÓÃdirµÃµ½Ä¿Â¼ÖеÄÎļþµÄÃû×Ö£¬È»ºóÓÃmap»òforÖ®ÀàµÄ¶Ôÿһ¸öÎļþ½øÐУº ¶Áµ½ÄÚ´æÖУ¬È»ºóÀûÓÃ×Ö·û´®Ìæ»»²Ù×÷Ìæ»»£¬ÔÙд»ØÈ¥ ÕâÑù¾Í¿ÉÒÔÁË°É£¬²»ÖªµÀ»¹ÓÐûÓиüºÃµÄ°ì·¨¡£ ÔÚ07-1-12£¬Kid. Jiang <kid.jiang在gmail.com> дµÀ£º Çë½ÌÔÚÒ»¸öĿ¼ÖÐÓÐN¸öTXTÎļþ,ÏÖÔÚÐèÒª¶Ôÿ¸öTXTÀïµÄijһÏàͬ×ֶνøÐÐÌæ´ú,ÇëÎʸÃÔõô²Ù×÷? -- Thank you Kid.Jiang _______________________________________________ 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 --------------------------------- ÇÀ×¢ÑÅ»¢Ãâ·ÑÓÊÏä-3.5GÈÝÁ¿£¬20M¸½¼þ£¡ -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070113/186b1b5a/attachment-0001.htm
Zeuux © 2025
京ICP备05028076号