零基础学python-8.2 列表的基本操作、迭代和解析
基本操作:使用+和*
>>> a='http://blog.csdn.net/raylee2007' >>> aList=['123',123,123.0] >>> bList=['dd',a,['123','aaa']] >>> aList+bList ['123', 123, 123.0, 'dd', 'http://blog.csdn.net/raylee2007', ['123', 'aaa']] >>>
迭代:
>>> 3 in [1,2,3] True >>> for x in range(5):print(x) 0 1 2 3 4 >>>
>>> result=[x*3 for x in 'my date'] >>> result ['mmm', 'yyy', ' ', 'ddd', 'aaa', 'ttt', 'eee'] >>>
就说到这里,谢谢大家
------------------------------------------------------------------
版权声明:本文为博主原创文章,未经博主允许不得转载。