Awesome python code style [List]

来源:互联网 发布:usb网络共享打不开 编辑:程序博客网 时间:2024/05/16 06:49

1.A = B ? a1:a2

A = (a1, a2)[B == True]

2.List comprehension

a = [i in range(10) if i%2==0]b = [(x,y) for x in range(5) for y in range(3)]

3.read file

with open(filename) as f:    image_index = [x.strip() for x in f.readlines()]
0 0