25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 
 
 

31 lines
633 B

  1. import sys
  2. def build_airport_dict():
  3. result = dict()
  4. stream = open("airports.txt", "r")
  5. contents = stream.read()
  6. lines = contents.splitlines()
  7. for line in lines:
  8. words = line.split(" ", maxsplit=1)
  9. assert len(words) == 2
  10. code = words[0]
  11. name = words[1].strip()
  12. result[code] = name
  13. return result
  14. def main():
  15. if len(sys.argv) < 2:
  16. sys.exit("Not enough arguments")
  17. airport_dict = build_airport_dict()
  18. code = sys.argv[1]
  19. if code not in airport_dict:
  20. sys.exit("Code not found")
  21. result = airport_dict[code]
  22. print(result)
  23. main()