SHARE
TWEET

Untitled

a guest Jun 16th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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  名古屋市
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top