Explain Word _ looks a bit like Python tuple dictionary (named Ganso)

1. The need for a library namedtuple:

  Named tuples is called for each element of the tuple named, it looks like access to a dictionary.

  Examples

from collections import namedtuple

Stock = namedtuple('stock','open high low close')
stock = Stock(200,300,400,500)
print(stock)
# stock(open=200, high=300, low=400, close=500)
print(stock.open)
# 200

  Note 1: In fact, naming tuple is equal to a named parameter passing to form a tuple, in fact, a good description of it here, open = 100, of such parameters, why use a tuple to save.

  Note 2: Note that the definition of each element corresponding to the name, the required space separation. The first parameter is the name of the tuple, the second argument is a string of space-separated properties.

Guess you like

Origin www.cnblogs.com/noah0532/p/10959996.html