import csv
import simplekml
import codecs
def main():
print("hello")
print("hello again")
kml=simplekml.Kml()
with codecs.open('RMCQ1.csv','r',encoding='utf-8') as f:
inputfile = csv.reader(f)
inputfile.next()
for row in inputfile:
print("yes")
pnt = kml.newpoint(name=row[1],coords=[(row[2],row[3],row[4])])
print("yes gaain")
kml.save('RMCQ1.kml')
if __name__ == '__main__':
main()
我正在尝试运行上面的代码,我收到此错误:
hello
hello again
Traceback (most recent call last):
File "/Users/nidhikantak/Desktop/kml/kmlconverter.py", line 18, in <module>
main()
File "/Users/nidhikantak/Desktop/kml/kmlconverter.py", line 11, in main
inputfile.next()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 699, in next
return self.reader.next()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 630, in next
line = self.readline()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 545, in readline
data = self.read(readsize, firstline=True)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 492, in read
newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xee in position 0: invalid continuation byte
我该如何解决这个错误?