python 为每个元组元素命名

 

 

代码:

#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import namedtuple

Student = namedtuple('Student',['name','age','email'])

s = Student('jim','16','14@qq.com')

print(s.name)

 

posted @ 2022-04-14 10:47  wanghhhh  阅读(27)  评论(0)    收藏  举报