test2.py 404 B

1234567891011121314151617181920212223
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. '''
  4. @Auther :liuyuqi.gov@msn.cn
  5. @Time :2018/4/14 4:56
  6. @File :test2.py
  7. '''
  8. ls = [1,2,3,4]
  9. list1 = [i for i in ls if i>2]
  10. print list1
  11. list2 = [i*2 for i in ls if i>2]
  12. print list2
  13. dic1 = {x: x**2 for x in (2, 4, 6)}
  14. print dic1
  15. dic2 = {x: 'item' + str(x**2) for x in (2, 4, 6)}
  16. print dic2
  17. set1 = {x for x in 'hello world' if x not in 'low level'}
  18. print set1