Python JSON module has no attribute 'dumps'

前端 未结 10 1852
攒了一身酷
攒了一身酷 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:38

    Even I was facing similar error while running json.dump(). In my case I was getting an error string :

    AttributeError: 'file' object has no attribute 'dump'

    How I fixed it -

    I was using variable name as "json" for File descriptor in the same script, which is why I was getting this error. So I simply renamed that variable name and issue resolved.

提交回复
热议问题