代码拉取完成,页面将自动刷新
#dicts about its' operation
states = {
'Beijing': 'BJ',
'Guangxi': 'GX',
'Hubei': 'HB',
'Guangdong': 'GD',
'Hunan': 'HN'
}
cities = {
'BJ': 'Beijing',
'HN': 'Changsha',
'HB': 'Wuhan',
'GD': 'Gaungzhou'
}
cities['SC'] = 'Sichuan'
cities['GX'] = 'Guangxi'
print('-' * 10)
print('SC state has: ', cities['SC'])
print('GX state has: ', cities['GX'])
print('-' * 10)
print('Beijing\' abbereviation is: ', states['Beijing'])
print('Guangdong\' abbereviation is: ', states['Guangdong'])
print('-' * 10)
print('Beijing\' has: ', cities[states['Beijing']])
print('Guangdong\' has: ', cities[states['Guangdong']])
print('-' * 10)
for state, abbrev in list(states.items()):
print(f"{state} is abbreviated {abbrev}")
print('-' * 10)
for abbrev, city in list(cities.items()):
print(f"{abbrev} has the city {city}")
print('-' * 10)
for state, abbrev in list(states.items()):
print(f"{state} is abbreviated {abbrev}")
print(f"and has the city {cities[abbrev]}")
print('-' * 10)
state = states.get('Sichuan')
if not state:
print("Sorry, no Sichuan.")
#with default values
city = cities.get('TJ','Does Not Exist')
print(f"The city for the state 'TJ' is : {city}")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。