本帖最后由 jackz007 于 2021-3-30 00:29 编辑
- import random
- d = [i + 1 for i in range(48)]
- e = []
- for x in d[:]:
- i = random . choice(d)
- e . append(i)
- d . remove(i)
- d = []
- for i in range(8):
- x = []
- for j in range(6):
- x . append(e[i * 6 + j])
- d . append(x)
- print(d)
复制代码
运行实况
- D:\00.Excise\Python>python x.py
- [[42, 14, 34, 4, 2, 47], [43, 5, 24, 30, 10, 27], [16, 35, 26, 17, 45, 7], [38,48, 1, 8, 18, 36], [32, 25, 44, 21, 40, 28], [39, 13, 46, 19, 11, 6], [22, 31, 23, 29, 41, 15], [37, 20, 3, 9, 33, 12]]
- D:\00.Excise\Python>
复制代码 |