Level : WORDPRESS BOOK LINKEDIN PATENT Send Mail 동냥하기 hajunho.com

namedtuple

XaaS/FireBase / / 2020. 4. 8. 07:21
반응형

from collections import namedtuple
# or
import collections

param4tuple = ['name', 'age', 'sex', 'address', 'phoneNumber']
personcardskim = namedtuple('whatever1', param4tuple, defaults=(None,) * len(param4tuple))
person001 = personcardskim('Eddie')
print('person001 =', person001)

personcardskim2 = namedtuple('whatever2', 'name age sex address phoneNumber')
person002 = personcardskim2('joe', '34', 'male', 'korea', '01022223333')

print('person002 =',  person002)

difficultTuple = namedtuple('whatever3', ['name', 'age', 'sex'])
person003 = difficultTuple('helloman', '18', 'male')
print('person003 = ', person003)

importTuple = collections.namedtuple('whatever4', 'name age sex', defaults=(None,) * 3)
person004 = importTuple('haha')
print('person004 = ', person004)

 

 

 

 


 

person001.name

Out[3]: 'Eddie'

person002.name

Out[4]: 'joe'

person003.name

Out[5]: 'helloman'

person004.name

Out[6]: 'haha'

반응형

'XaaS > FireBase' 카테고리의 다른 글

barcode -> QRcode 변경  (0) 2020.06.17
오늘자 troubleshooting  (0) 2020.04.08
python.c  (0) 2020.04.08
decision science - 2  (0) 2020.04.08
지금 최고의 AI 스피커는?  (0) 2020.04.08
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기