I get the error "Key error:'name' "
Can anyone tell what the problem is with the following code:
import random
def mongoCountry(countryNum, provinceNum):
"""generate some test data"""
f = open("F:\\univData\\country-mongo.json", mode = 'w')
text = ""
for c_n in range(0, countryNum):
for p_n in range(0, provinceNum):
text += "{name:country{0},provinces:[{$ref : Province,$id : province{1}}]}\n".format(c_n, p_n)
f.write(text)
f.close()
mongoCountry(2, 10)
I googled it so I know it's about dict() object. but I can't find any such object there.