小编Cac*_*ses的帖子

如何在Python中按顺序打印为类创建的所有变量的列表?

我有以下课程:

class Countries(object):
    def __init__(self, country_capital, country_population):
        self.capital = country_capital
        self.population = country_population
Run Code Online (Sandbox Code Playgroud)

以及连接到类的变量列表:

france = Countries("Paris", "66")
england = Countries("London", "53")
usa = Countries("Washington, DC", "318")
germany = Countries("Berlin", "80")
Run Code Online (Sandbox Code Playgroud)

我如何按人口顺序查看国家()首都?例如["伦敦","巴黎","柏林","华盛顿特区"]

python variables class

1
推荐指数
1
解决办法
37
查看次数

标签 统计

class ×1

python ×1

variables ×1