dicttoxml抛出AttributeError

时间:2019-06-14 23:08:15

标签: python-3.x attributeerror dicttoxml

我尝试检查dicttoxml的工作方式。但是我从dicttoxml模块中收到此错误。 我正在从geany启动程序。 有人可以帮忙吗? 谢谢!

import dicttoxml

myDict = {'myKey':"theirValue"};

xml =dicttoxml.dicttoxml(myDict);

输出为:

martin@saturn:~/it/python/python_work$ /bin/sh /tmp/geany_run_script_Q2NH3Z.sh
0.32000000000000006
1.6666666666666667
['1', '6666666666666667']

Traceback (most recent call last):
  File "dicttoxmlExmp.py", line 4, in <module>
    xml =dicttoxml.dicttoxml(myDict);
  File "/home/martin/.local/lib/python3.6/site-packages/dicttoxml.py", line 393, in dicttoxml
    convert(obj, ids, attr_type, item_func, cdata, parent=custom_root), 
  File "/home/martin/.local/lib/python3.6/site-packages/dicttoxml.py", line 176, in convert
    if isinstance(obj, numbers.Number) or type(obj) in (str, unicode):
AttributeError: module 'numbers' has no attribute 'Number'

1 个答案:

答案 0 :(得分:0)

您可以简单地做到:

  

python yourscript

与其将其作为Shell脚本运行。