例子
#coding=utf-8
import sys
test_list = [x*x for x in range(10) if x % 3 == 0]
print(test_list)
num_list = [(x, y) for x in range(3) for y in range(3)]
print(num_list)
for x in range(0, 10):
print(x)
log:
E:\BACnet\work\aaa\Scripts\python.exe E:/python/work/flask/aaa/aa.py
[0, 9, 36, 81]
[(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
0
1
2
3
4
5
6
7
8
9
Process finished with exit code 0