Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class CityNameMapping(object):
  2. CITY_NAME_MAPPING = {}
  3.  
  4. with open('data/city.csv', 'r') as file:
  5. data = file.read()
  6. if not data.startswith("#"):
  7. city_entry = data.split('t')
  8. CITY_NAME_MAPPING[city_entry[1]] = city_entry[0]
  9.  
  10. @classmethod
  11. def get_mapping(cls, city):
  12. if city in cls.CITY_NAME_MAPPING:
  13. return cls.CITY_NAME_MAPPING[city]
  14. else:
  15. print("No city name found: {} ".format(city))
  16. return None
  17.  
  18. Nagoya 名古屋市
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement