Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入json2xml库时出现无效语法错误_Python - Fatal编程技术网

Python 导入json2xml库时出现无效语法错误

Python 导入json2xml库时出现无效语法错误,python,Python,我正在尝试导入以下库: import json2xml from json2xml.utils import readfromstring 但是,当我执行第二行时,会出现以下错误: Traceback (most recent call last): File "C:\Users\denis\Desktop\Pazaruvaj Upload\Pazaruvaj_Part1_Test.py", line 12, in <module> from jso

我正在尝试导入以下库:

import json2xml
from json2xml.utils import readfromstring
但是,当我执行第二行时,会出现以下错误:

Traceback (most recent call last):
  File "C:\Users\denis\Desktop\Pazaruvaj Upload\Pazaruvaj_Part1_Test.py", line 12, in <module>
    from json2xml.utils import readfromurl, readfromstring, readfromjson
  File "C:\Python27\lib\site-packages\json2xml\utils.py", line 19
    def readfromjson(filename: str) -> dict:
                             ^
SyntaxError: invalid syntax
回溯(最近一次呼叫最后一次):
文件“C:\Users\denis\Desktop\Pazaruvaj Upload\Pazaruvaj_Part1_Test.py”,第12行,在
从json2xml.utils导入readfromurl、readfromstring、readfromjson
文件“C:\Python27\lib\site packages\json2xml\utils.py”,第19行
def readfromjson(文件名:str)->dict:
^
SyntaxError:无效语法
无法在网上找到有关此问题的任何信息

注意:我没有从json2xml导入json2xml编写
,因为它给出了相同的错误

根据,json2xml与Python2不兼容


Python2已弃用,请更新为Python3。那么这个图书馆应该可以用了。

谢谢!我没想到要检查一下。