zed Shaw の本「learning python the hard way」を読んでいます。申し訳ありませんが、私はコーディングの初心者であり、これを理解するのに苦労しています. 州に入って返される都市をfind_city関数がどのように見つけるかがわかりません。「わかりました注意してください」と「 # この行はこれまでで最も重要です! 勉強してください! の行は、私を混乱させるものです.
cities = {'CA': 'San Francisco', 'MI': 'Detroit',
'FL': 'Jacksonville'}
cities['NY'] = 'New York'
cities['OR'] = 'Portland'
def find_city(themap, state):
if state in themap:
return themap[state]
else:
return "Not found."
# ok pay attention!
cities['_find'] = find_city
while True:
print "State? (ENTER to quit)",
state = raw_input("> ")
if not state: break
# this line is the most important ever! study!
city_found = cities['_find'](cities, state)
print city_found