导入pykml.factory时出现语法错误

时间:2017-11-20 21:44:57

标签: python python-3.x python-module

所以我尝试使用pyKML为google earth创建一个KML文件,但是当我尝试导入模块时,我得到以下内容:

 from pykml.factory import KML_ElementMaker as KML
Traceback (most recent call last):

  File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 2862, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-69-cdeb04502fb8>", line 1, in <module>
    from pykml.factory import KML_ElementMaker as KML

  File "C:\Anaconda\lib\site-packages\pykml\factory.py", line 216
    print write_python_script_for_kml_document(doc)
                                             ^
SyntaxError: invalid syntax

我尝试使用simpleKML,但它不适用于python 3.6

1 个答案:

答案 0 :(得分:1)

print write_python_script_for_kml_document(doc)

是一行代码,在Python 2中有效,但在Python 3中不行。由于Python 3需要括号:

print(write_python_script_for_kml_document(doc))

所以我猜你试图使用的库还没有适应Python 3.或者至少这个版本没有。