[i*2 for i in x]

>>> x
[1, 2, 3, 4, 5]
>>> y
['1', '2', '3', '4', '5']
>>> x+y
[1, 2, 3, 4, 5, '1', '2', '3', '4', '5']
>>> x*5
[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]
>>> x
[1, 2, 3, 4, 5]
>>> x.*5
  File "<stdin>", line 1
    x.*5
      ^
SyntaxError: invalid syntax
>>> [i*2 for i in x]
[2, 4, 6, 8, 10]
>>> x
[1, 2, 3, 4, 5]
>>>

 

posted @ 2018-01-17 13:46  sky20080101  阅读(168)  评论(0)    收藏  举报