Python JSON module has no attribute 'dumps'

前端 未结 10 1731
攒了一身酷
攒了一身酷 2021-01-01 09:14

I am running Python 2.7 (x64 Linux) and trying to convert a dict to a JSON object.

>>> import sys
>>> sys.version_info
sys.ver         


        
10条回答
  •  自闭症患者
    2021-01-01 09:36

    Had a similar issues, it was caused by another custom module. I named another script json.py and it turns out it tried to load the custom json.py file as a module. dumps method is obviously not available there.

    Renaming the json.py script to something else (json2.py) got rid of the issue.

提交回复
热议问题