私信  •  关注

Rohit Gawas

Rohit Gawas 最近创建的主题
Rohit Gawas 最近回复了
5 年前
回复了 Rohit Gawas 创建的主题 » 需要有关python 3.7的简单脚本的帮助[duplicate]

您可以使用字典:

x = 0
y = 1
z = 3
list=[]
dict = {0: 'c', 1: 'd', 2: 'e', 3: 'f'}
if x in dict:
    list.append(dict[x])
else:
    pass

if y in dict:
    list.append(dict[y])
else:
    pass
if z in dict:
    list.append(dict[z])
else:
    pass

print list