2005年09月05日 星期一 16:35
在 05-9-5,广星<guangxing at ict.ac.cn> 写道: > 这些方法之类的您是怎么来查,又从哪里来查到呢? 无它,唯手熟而。程序写多了,自然就记住了,顶多查下语法,代码就出来了。 -- I like python! My Donews Blog: http://www.donews.net/limodou
2005年09月05日 星期一 20:58
如果str = 'dfsdf sdfsdf sdfsdf dsf dfdf dfdf' 我要按n(不定值)个空格来分,怎么办? On 9/5/05, limodou <limodou at gmail.com> wrote: > > 在 05-9-5,广星<guangxing at ict.ac.cn> 写道: > > 这些方法之类的您是怎么来查,又从哪里来查到呢? > > 无它,唯手熟而。程序写多了,自然就记住了,顶多查下语法,代码就出来了。 > > -- > I like python! > My Donews Blog: http://www.donews.net/limodou > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- Yours, fluke fluke at sfcube.net http://sfcube.net/blog -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050905/876e8242/attachment.html
2005年09月05日 星期一 21:19
perl的语法是这样的。 $_ = 'dfsdf sdfsdf sdfsdf dsf dfdf dfdf'; @str_list = splite(/ +/); #一个或多个空格/ +/ python 也可以吧,我又猜。 ----- Original Message ----- From: Fluke To: limodou at gmail.com ; python-chinese at lists.python.cn Sent: Monday, September 05, 2005 8:58 PM Subject: Re: Re: [python-chinese]如何把字符串中按空格分开的元素分别提取出 来? 如果str = 'dfsdf sdfsdf sdfsdf dsf dfdf dfdf' 我要按n(不定值)个空格来分,怎么办? On 9/5/05, limodou <limodou at gmail.com> wrote: 在 05-9-5,广星<guangxing at ict.ac.cn> 写道: > 这些方法之类的您是怎么来查,又从哪里来查到呢? 无它,唯手熟而。程序写多了,自然就记住了,顶多查下语法,代码就出来了。 -- I like python! My Donews Blog: http://www.donews.net/limodou _______________________________________________ python-chinese list python-chinese at lists.python.cn http://python.cn/mailman/listinfo/python-chinese -- Yours, fluke fluke at sfcube.net http://sfcube.net/blog ---------------------------------------------------------------------------- -- _______________________________________________ python-chinese list python-chinese at lists.python.cn http://python.cn/mailman/listinfo/python-chinese -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20050905/e688f5f7/attachment.htm
2005年09月05日 星期一 21:26
Fluke wrote: > 如果str = 'dfsdf sdfsdf sdfsdf dsf dfdf dfdf' > 我要按n(不定值)个空格来分,怎么办? In [9]: s = 'dfsdf sdfsdf sdfsdf dsf dfdf dfdf' In [10]: n = 2 In [11]: s.split(' ' * n) Out[11]: ['dfsdf sdfsdf sdfsdf', 'dsf', ' dfdf dfdf'] In [12]: import re In [13]: re.split(' ' * n + '+', s) Out[13]: ['dfsdf sdfsdf sdfsdf', 'dsf', 'dfdf dfdf'] -- Qiangning Hong http://www.hn.org/hongqn (RSS: http://feeds.feedburner.com/hongqn) Registered Linux User #396996 Get Firefox! <http://www.spreadfirefox.com/?q=affiliates&id;=67907&t;=1> Thunderbird! <http://www.spreadfirefox.com/?q=affiliates&id;=67907&t;=183>
Zeuux © 2025
京ICP备05028076号