PYTHON 点滴

# 具名元组
>>> from collections import namedtuple >>> City = namedtuple('City', 'name country population coordinates') ➊ >>> tokyo = City('Tokyo', 'JP', 36.933, (35.689722, 139.691667)) ➋ >>> tokyo City(name='Tokyo', country='JP', population=36.933, coordinates=(35.689722, 139.691667)) >>> tokyo.population ➌ 36.933 >>> tokyo.coordinates (35.689722, 139.691667) >>> tokyo[1] 'JP'

 

## 

posted @ 2021-06-07 14:07  小毛编  阅读(22)  评论(0编辑  收藏  举报