[python-chinese] 如何从元组中提取元素
Jerry
jetport在gmail.com
星期四 八月 2 15:34:54 HKT 2007
>
>
> ÎÒÏëÌáÈ¡header[1]µ±ÖеÄÕâЩÊý¾Ý£¬À´»Í¼£¬
> >>> print header[1]
> ((('SurfaceTemp', 1),), 22, [('328 ',), ('284 ',), ('222 ',), ('204 ',),
> ('158 ',), ('115 ',), ('101 ',), ('97 ',), ('83 ',), ('70 ',), ('62 ',),
> ('53 ',), ('54 ',), ('48 ',), ('43 ',), ('36 ',), ('102 ',), ('144 ',),
> ('269 ',), ('285 ',), ('371 ',), ('385 ',)])
> >>> type(header[1][2])
> <type 'list'>
> >>> print header[1][2]
> [('328 ',), ('284 ',), ('222 ',), ('204 ',), ('158 ',), ('115 ',), ('101
> ',), ('97 ',), ('83 ',), ('70 ',), ('62 ',), ('53 ',), ('54 ',), ('48
> ',), ('43 ',), ('36 ',), ('102 ',), ('144 ',), ('269 ',), ('285 ',), ('371
> ',), ('385 ',)]
> >>> print header[1][2][1]
> ('284 ',)
> >>> type(header[1][2][1])
> <type 'tuple'>
>>> l = [ i[0] for i in header[1][2] ]
ÄãÐèÒªÕâÑùµÄ½á¹ûÂð£¿
Ìá³öÀ´µÄÊýÈÔÈ»ÊÇÔª×飬²»ÖªµÀÔõô²ÅÄÜÌáÈ¡³ölist£¬listµ±ÖÐÒªÊÇ×Ö·û»òÕßÊý×ֵġ£
>
> ÐÂÊÖÎÊÌ⣬´ó¼Ò²»ÒªÐ¦»°°¡£¬»¶ÓÓ»Ô¾·¢ÑÔ¡£
>
>
--
If U can see it, then U can do it
If U just believe it, there's nothing to it
I believe U can fly
JetPort:80
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070802/cd3d672e/attachment.html
关于邮件列表 python-chinese 的更多信息