Loading...
Loading...
Loading...

Catalog


python奇淫巧计

计算机编程 Pub Time:2022/9/14/16:55 881 vk python python高级 python奇淫巧计 最近编辑于2 years, 8 months前 Target reading time:1min

定义和使用具名元组

创建具名元组

In [1]: from collections import namedtuple

In [2]: City = namedtuple('City', 'name country population coordinates')

In [3]: tokyo = City('Tokyo', 'JP', 36.933, (35.689722, 139.691667))

In [4]: tokyo
Out[4]: City(name='Tokyo', country='JP', population=36.933, coordinates=(35.689722, 139.691667))
单词数:39字符数:323

共有0条评论