您可以在Python 3.6的一行中创建多个变量吗

时间:2019-05-20 09:34:33

标签: python python-3.x

我有很多变量都具有相同的值,但是它们需要不同的变量,以便可以区分。

我还没有尝试过任何东西。

您能这样做吗?

a, b, c = []
e, f, g = 1

1 个答案:

答案 0 :(得分:2)

您可以这样做:

gcloud compute --project=PROJECT_ID ssh --zone "VM_ZONE" "VM_NAME" --command="sudo rm -rf /path/to/aux/dir/ && sudo mkdir /path/to/aux/dir/ && cd /path/to/aux/dir/ && sudo git clone https://BITBUCKET_USERNAME:BITBUCKET_PASSWORD@BITBUCKET_REPOSITORY . >> /dev/null 2>&1 && sudo rsync -a --delete /path/to/aux/dir/ /path/to/code/dir/"

只是它们是相同的对象。

但是您也可以这样做:

a = b = c = []
e = f = g = 1

但不要让它们成为同一对象:

a, b, c = [[]] * 3
e, f, g = [1] * 3