dicttoxml выбрасывает AttributeError - PullRequest
1 голос
/ 15 июня 2019

Я пытаюсь проверить, как работает 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 голосов
/ 16 июня 2019

Вы можете просто сделать:

python yourscript

Вместо запуска в качестве сценария оболочки.

...