Dictionary of Python Automation

Source: Internet
Author: User

#Author Wangmengzhu

# #clear
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# dic.clear ()
# Print (DIC)

# #copy
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.copy ()
# print (v)
# Print (DIC)
# {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# {' K1 ': ' v1 ', ' K2 ': ' V2 '}

# #fromkeys
# dic = {}
# dic = Dic.fromkeys ([' K1 ', ' K2 '], ' num ')
# Print (DIC)
##{' K1 ': ' num ', ' K2 ': ' Num '}

# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.get (' K1 ')
# print (v) # #获取键值

# #返回字典中所有的键值对
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.items ()
# print (v)


# #用于返回字典中的键
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = Dic.keys ()
# print (v)




# #获取并删除对应的value值
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.pop (' K1 ')
# print (v)
# Print (DIC)



# #随机删除一个键值对, and get the deleted key value
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.popitem ()
# print (v)
# Print (DIC)

# #增加, if there is no action on the key value pair
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.setdefault (' K3 ', ' v3 ')
# print (v)
# Print (DIC)


# #批量增加或者修改
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.update ({' K3 ': ' V3 ', ' K1 ': ' V6 '})
# Print (DIC)

# #取出字典中的值
# dic = {' K1 ': ' v1 ', ' K2 ': ' V2 '}
# v = dic.values ()
# print (v)

Dictionary of Python Automation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.