2007年06月22日 星期五 12:12
ÎÒ¸Õ¿ªÊ¼½Ó´¥python£¬Åöµ½Á˸öСÎÊÌ⣬²»ÖªµÀÔõô½â¾ö£¬Çë´ó¼Ò°ï°ï棬ллÁË¡£ ÎÊÌâÊÇÕâÑùµÄ£º Ò»¸ö×Ö·û´®£º str1 = "abc123£¬#ÄãÎÒËû" ÎÒÏ£Íû°ÑËü²ð·Ö³ÉÒ»¸ölist£º ca1[0] = 'a' ca1[1] = 'b' ca1[2] = 'c' ca1[3] = '1' ca1[4] = '2' ca1[5] = '3' ca1[6] = '£¬' ca1[7] = '#' ca1[8] = 'Äã' ca1[9] = 'ÎÒ' ca1[10] = 'Ëû' -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070622/281bfe48/attachment.htm
2007年06月22日 星期五 12:17
>>> l = list(unicode(str1, 'gbk')) >>> l [u'a', u'b', u'c', u'1', u'2', u'3', u'\uff0c', u'#', u'\u4f60', u'\u6211', u'\u4ed6'] >>> for i in l: print i a b c 1 2 3 £¬ # Äã ÎÒ Ëû ÔÚ07-6-22£¬fei. He <hefei267在gmail.com> дµÀ£º > > ÎÒ¸Õ¿ªÊ¼½Ó´¥python£¬Åöµ½Á˸öСÎÊÌ⣬²»ÖªµÀÔõô½â¾ö£¬Çë´ó¼Ò°ï°ï棬ллÁË¡£ > > ÎÊÌâÊÇÕâÑùµÄ£º > > Ò»¸ö×Ö·û´®£º > str1 = "abc123£¬#ÄãÎÒËû" > > ÎÒÏ£Íû°ÑËü²ð·Ö³ÉÒ»¸ölist£º > ca1[0] = 'a' > ca1[1] = 'b' > ca1[2] = 'c' > ca1[3] = '1' > ca1[4] = '2' > ca1[5] = '3' > ca1[6] = '£¬' > ca1[7] = '#' > ca1[8] = 'Äã' > ca1[9] = 'ÎÒ' > ca1[10] = 'Ëû' > > _______________________________________________ > 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/20070622/174c6697/attachment.html
2007年06月22日 星期五 14:17
ÕâÖÖÇé¿ö²»ÐèÒª²ð·Ö°É£¬×Ö·û´®¾ÍÊÇsequence£¬ÓÃϱê»òÕßfor s in str1¶¼¿ÉÒÔѽ£¬Èç¹ûÓÐÖÐÎÄ»¹ÊÇȷʵÐèÒªunicodeÒ»Ï嵀 str1 = unicode("abc123£¬#ÄãÎÒËû",'gbk') >>> for i in range(len(str1)): print str1[i] a b c 1 2 3 £¬ # Äã ÎÒ Ëû >>> >>> for s in str1: print s a b c 1 2 3 £¬ # Äã ÎÒ Ëû -----Original Message----- From: python-chinese-bounces在lists.python.cn [mailto:python-chinese-bounces在lists.python.cn]On Behalf Of lai yonghao Sent: Friday, June 22, 2007 12:18 PM To: python-chinese在lists.python.cn Subject: Re: [python-chinese]ÇóÖú£ºÈçºÎ²ð·ÖÒ»¸ö×Ö·û´®£¿ >>> l = list(unicode(str1, 'gbk')) >>> l [u'a', u'b', u'c', u'1', u'2', u'3', u'\uff0c', u'#', u'\u4f60', u'\u6211', u'\u4ed6'] >>> for i in l: print i a b c 1 2 3 £¬ # Äã ÎÒ Ëû ÔÚ07-6-22£¬fei. He < hefei267在gmail.com> дµÀ£º ÎÒ¸Õ¿ªÊ¼½Ó´¥python£¬Åöµ½Á˸öСÎÊÌ⣬²»ÖªµÀÔõô½â¾ö£¬Çë´ó¼Ò°ï°ï棬ллÁË¡£ ÎÊÌâÊÇÕâÑùµÄ£º Ò»¸ö×Ö·û´®£º str1 = "abc123£¬#ÄãÎÒËû" ÎÒÏ£Íû°ÑËü²ð·Ö³ÉÒ»¸ölist£º ca1[0] = 'a' ca1[1] = 'b' ca1[2] = 'c' ca1[3] = '1' ca1[4] = '2' ca1[5] = '3' ca1[6] = '£¬' ca1[7] = '#' ca1[8] = 'Äã' ca1[9] = 'ÎÒ' ca1[10] = 'Ëû' _______________________________________________ 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/20070622/39e738c2/attachment.htm
2007年06月23日 星期六 08:53
ÎÊÌâÒѾ½â¾öÁË£¬Ð»Ð»Á½Î» ÔÚ07-6-22£¬Liming_Do <Liming_Do在smics.com> дµÀ£º > > ÕâÖÖÇé¿ö²»ÐèÒª²ð·Ö°É£¬×Ö·û´®¾ÍÊÇsequence£¬ÓÃϱê»òÕßfor s in str1¶¼¿ÉÒÔѽ£¬Èç¹ûÓÐÖÐÎÄ»¹ÊÇȷʵÐèÒªunicodeÒ»Ï嵀 > str1 = unicode("abc123£¬#ÄãÎÒËû",'gbk') > > >>> for i in range(len(str1)): > print str1[i] > > > a > b > c > 1 > 2 > 3 > £¬ > # > Äã > ÎÒ > Ëû > >>> > > > >>> for s in str1: > print s > > > a > b > c > 1 > 2 > 3 > £¬ > # > Äã > ÎÒ > Ëû > > -----Original Message----- > *From:* python-chinese-bounces在lists.python.cn [mailto: > python-chinese-bounces在lists.python.cn]*On Behalf Of *lai yonghao > *Sent:* Friday, June 22, 2007 12:18 PM > *To:* python-chinese在lists.python.cn > *Subject:* Re: [python-chinese]ÇóÖú£ºÈçºÎ²ð·ÖÒ»¸ö×Ö·û´®£¿ > > >>> l = list(unicode(str1, 'gbk')) > >>> l > [u'a', u'b', u'c', u'1', u'2', u'3', u'\uff0c', u'#', u'\u4f60', > u'\u6211', u'\u4ed6'] > >>> for i in l: > print i > > > a > b > c > 1 > 2 > 3 > £¬ > # > Äã > ÎÒ > Ëû > > > ÔÚ07-6-22£¬fei. He <hefei267在gmail.com> дµÀ£º > > > > ÎÒ¸Õ¿ªÊ¼½Ó´¥python£¬Åöµ½Á˸öСÎÊÌ⣬²»ÖªµÀÔõô½â¾ö£¬Çë´ó¼Ò°ï°ï棬ллÁË¡£ > > > > ÎÊÌâÊÇÕâÑùµÄ£º > > > > Ò»¸ö×Ö·û´®£º > > str1 = "abc123£¬#ÄãÎÒËû" > > > > ÎÒÏ£Íû°ÑËü²ð·Ö³ÉÒ»¸ölist£º > > ca1[0] = 'a' > > ca1[1] = 'b' > > ca1[2] = 'c' > > ca1[3] = '1' > > ca1[4] = '2' > > ca1[5] = '3' > > ca1[6] = '£¬' > > ca1[7] = '#' > > ca1[8] = 'Äã' > > ca1[9] = 'ÎÒ' > > ca1[10] = 'Ëû' > > > > _______________________________________________ > > 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/20070623/ab6b4ec2/attachment.html
2007年06月23日 星期六 11:49
2007年06月23日 星期六 14:32
str1 = "abc123,#你我他" cal = list(str1) fei.He 写道: > 我刚开始接触python,碰到了个小问题,不知道怎么解决,请大家帮帮忙,谢谢了。 > > 问题是这样的: > > 一个字符串: > str1 = "abc123,#你我他" > > 我希望把它拆分成一个list: > ca1[0] = 'a' > ca1[1] = 'b' > ca1[2] = 'c' > ca1[3] = '1' > ca1[4] = '2' > ca1[5] = '3' > ca1[6] = ',' > ca1[7] = '#' > ca1[8] = '你' > ca1[9] = '我' > ca1[10] = '他' > ------------------------------------------------------------------------ > > _______________________________________________ > 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/20070623/90920067/attachment.html
2007年06月23日 星期六 15:48
ÎÒÒ²ÊÇÐÂÊÖ£¬ÊÔһϠstr1="abc123£¬#ÄãÎÒËû" cal=[] for str in str1: cal.append(str) print cal taohe 2007-06-23 ·¢¼þÈË£º XiaQ ·¢ËÍʱ¼ä£º 2007-06-23 14:29:38 ÊÕ¼þÈË£º python-chinese在lists.python.cn ³ËÍ£º Ö÷Ì⣺ Re: [python-chinese]ÇóÖú£ºÈçºÎ²ð·ÖÒ»¸ö×Ö·û´®£¿ str1 = "abc123£¬#ÄãÎÒËû" cal = list(str1) fei.He дµÀ: ÎÒ¸Õ¿ªÊ¼½Ó´¥python£¬Åöµ½Á˸öСÎÊÌ⣬²»ÖªµÀÔõô½â¾ö£¬Çë´ó¼Ò°ï°ï棬ллÁË¡£ ÎÊÌâÊÇÕâÑùµÄ£º Ò»¸ö×Ö·û´®£º str1 = "abc123£¬#ÄãÎÒËû" ÎÒÏ£Íû°ÑËü²ð·Ö³ÉÒ»¸ölist£º ca1[0] = 'a' ca1[1] = 'b' ca1[2] = 'c' ca1[3] = '1' ca1[4] = '2' ca1[5] = '3' ca1[6] = '£¬' ca1[7] = '#' ca1[8] = 'Äã' ca1[9] = 'ÎÒ' ca1[10] = 'Ëû' _______________________________________________ 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/20070623/56f692e9/attachment.htm
Zeuux © 2025
京ICP备05028076号