这是我的代码: -
import xml.etree.ElementTree as ET
filename= "kolkata_india.osm"
def count_tags(filename):
tags = {}
for event, elem in ET.iterparse(filename):
if elem.tag in tags:
tags[elem.tag] += 1
else:
tags[elem.tag] = 1
print tags
if __name__ == "__main__":
count_tags(filename)
C:\Python27\Udacity\mongodb>python mapparser.py
Traceback (most recent call last):
File "mapparser.py", line 17, in <module>
count_tags(filename)
File "mapparser.py", line 8, in count_tags
filename = kolkata_india.osm
NameError: global name 'kolkata_india' is not defined
这里我做错了什么?