如何使以下变量获取它们旁边的主变量的名称? (a,b,c,d)取决于MainVariable?
MainVariable = 'Shoe'
a = blackShoe
b = whiteShoe
c = blueShoe
d = yellowShoe
,如果更改为例如“ Tie” 然后
a = blackTie
b = whiteTie
c = blueTie
d = yellowTie
答案 0 :(得分:1)
a,b,c,d = [s + MainVariable for s in [a,b,c,d]]