The study dict and set in Python(20170906)
2017-09-06 20:58
483 查看
In this part, the immutable object(不可变对象) is important. That means the object cann’t be modify in any time. Only can change the direction of object.
print(information[‘yuhanyu’])
print(information[‘man’])
print(information)
print(num)
print(num2)
print(num2)
print(num2)
print(num | num2)
the dice(dictionary) and set inP Python
example dict
‘key’:value
information = {‘yuhanyu’:7,’guilin’:6,’man’:3}print(information[‘yuhanyu’])
modify the value of some key
information[‘man’] = 4print(information[‘man’])
delethe some key-value
information.pop(‘man’)print(information)
the dict of key is a immutable object(不可变对象 )
example set
num = set([5,6,7])print(num)
set([the is a list])
the set will delete repeat element
num2 = set([5,5,6,6,7,7])print(num2)
the add(element) function can increase a element to set
num2.add(8)print(num2)
the remove(element) function can delete a elemnet in set
num2.remove(5)print(num2)
the among of sets have intersection(交集) and union
print(num & num2)print(num | num2)
相关文章推荐
- The study of Class and Instance in Python(20170918)
- The study of list ,tuple and conditional statement in Python(20170905)
- The study of loop in Python(20170906)
- Styling Alert controls in Flex using the StyleManager class and setStyle() methods
- Python之dictAndset
- The study of calling fuction in Python(20170907)
- Do not request Window.FEATURE_ACTION_BAR and set windowActionBar to false in your theme to use a Toolbar instead
- The study of slice in Python(20170911)
- the usage of dict in python
- The study of Higher-order function in Python(20170913)
- Python-dict AND set
- How do I set the driver's python version in spark?
- The study of access restriction in Python(20170920) 访问限制
- How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:)
- the comprehensive description abut ‘copy’ and 'deepcopy' in python
- Less copies in Python with the buffer protocol and memoryviews
- The study of literation in Python(20170911)
- Python学习札记(九) Basic6 dict and set
- Whats is the difference between train, validation and test set, in neural networks?
- The study of map() and reduce() function in Python(20170913)