namedtuple的使用方法

from collections import namedtuple

card = namedtuple('card', ('rank', 'suit'))

kapai = card('A', 'red')

print(kapai)
print(kapai.rank)
print(kapai.suit)
posted @ 2020-01-06 10:23  菜菜_包包  阅读(586)  评论(0编辑  收藏  举报