有没有办法为多个变量分配相同的值或属性? [英] Is there a way to assign multiple variables a same value or attribute?
本文介绍了有没有办法为多个变量分配相同的值或属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Python中,有没有办法制作
In Python, is there a way to make
a, b, c, d, e = 'dog'
这样
a = 'dog'
b = 'dog'
#etc.
或
a, b, c, d, e = list()
这样
type(a through e)
返回
type 'list'
推荐答案
这里已经有人回答了:在 Javascript 中将多个变量设置为相同的值
在 python 中:
in python it would be:
a = b = c = d = e = 'dog'
它在 javascript 中相同,但以 'var' 开头:
its the same in javascript but with 'var' at the beginning:
var a = b = c = d = e = 'dog'
这篇关于有没有办法为多个变量分配相同的值或属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文