a="1,2,3"
b= a.split(",")
print(b)
print(type(b[1]))
print(",".join(b))
c = list()
for i in ['1','2','3']:
c.append(int(i))
print(c)
sum = 0
for i in range(1,6):
for j in range(1,6):
for k in range(1,6):
if i!= k and i != j and k != j:
sum += 1
print(i,j,k)
print(sum)
a=[1,2,3]
print(type(a))
b = [(1),(2),(3)]
print(type(b))
print(type(b[1]))
c = [(1,),(2,),(3,)]
print(type(c[1]))
colors = [ 'black',"white"]
sizes = [ "s","M","L"]
my_lis = list()
for i in sizes:
for k in colors:
my_lis.append((k,i))
print(my_lis)
方法二:
colors = [ 'black',"white"]
sizes = [ "s","M","L"]
print([(k,i) for i in sizes for k in colors])
import random
result = list()
for i in range(100000):
#骰子
a = random.randint(1,6)
#骰子
b = random.randint(1,6)
result.append(a+b)
result_dict = dict()
#把列表转化为集合
for i in set(result):
result_dict[i] = "{:.2%}".format(result.count(i) / 100000)
print(result_dict)