本文整理汇总了Python中dictionary.Dictionary.list方法的典型用法代码示例。如果您正苦于以下问题:Python Dictionary.list方法的具体用法?Python Dictionary.list怎么用?Python Dictionary.list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dictionary.Dictionary
的用法示例。
在下文中一共展示了Dictionary.list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from dictionary import Dictionary [as 别名]
# 或者: from dictionary.Dictionary import list [as 别名]
print("NY State has: %s" % cities.get('NY'))
print("OR State has: %s" % cities.get('OR'))
# print(some states
print('-' * 10)
print("Michigan's abbreviation is: %s" % states.get('Michigan'))
print("Florida's abbreviation is: %s" % states.get('Florida'))
# do it by using the state then cities dict
print('-' * 10)
print("Michigan has: %s" % cities.get(states.get('Michigan')))
print("Florida has: %s" % cities.get(states.get('Florida')))
# print(every state abbreviation
print('-' * 10)
states.list()
# print(every city in state
print('-' * 10)
cities.list()
print('-' * 10)
state = states.get('Texas')
if not state:
print("Sorry, no Texas.")
# default values using ||= with the nil result
# can you do this on one line?
city = cities.get('TX', 'Does Not Exist')
print("The city for the state 'TX' is: %s" % city)