博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

pythonic

Posted on 2017-09-19 18:29  bw_0927  阅读(113)  评论(0)    收藏  举报

a = [1, 2, 3, 4, 5, 6, 7, 8, 9]

print ','.join(str(x) for x in a)

1,2,3,4,5,6,7,8,9

 

print ','.join(str(x) for indx,x in enumerate(a) if indx < 5) 

1,2,3,4,5

 

 

> x = [i for i in a  if i not in b]