0
我有以下代码(Country
和City
类key_name
是数字ID与另外的“我”开头):如何优化向数据存储添加数据的代码?
def add_country(country, country_name):
if country and country_name and country_name != '':
return Country.get_or_insert('i'+str(country), country_name=country_name)
else:
return None
def add_city(city, city_name, country):
if country and city and city_name and city_name != '':
return City.get_or_insert('i'+str(city), city_name=city_name, parent=country)
else:
return None
它是正确的代码还是可以以某种方式优化?
实际上,这种问题会更好http://codereview.stackexchange.com/ – JMax
@JMax,codereview上没有与GAE相关的标签... –
您可以创建一些并至少用'Python'存在 – JMax