AttributeError: 'module' object has no attribute 'dumps'

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AttributeError: 'module' object has no attribute 'dumps'相关的知识,希望对你有一定的参考价值。

报错:

[[email protected] ~]# ./json.py 

DATA: [{‘a‘: ‘A‘, ‘c‘: 3.0, ‘b‘: (2, 4)}]

Traceback (most recent call last):

  File "./json.py", line 4, in <module>

    import json

  File "/root/json.py", line 8, in <module>

    data_string = json.dumps(data)

AttributeError: ‘module‘ object has no attribute ‘dumps‘


原因:脚本名字是json.py,导入的是我的脚本。所以出错


本文出自 “付炜超” 博客,谢绝转载!

以上是关于AttributeError: 'module' object has no attribute 'dumps'的主要内容,如果未能解决你的问题,请参考以下文章

python AttributeError: 'NoneType' object has no attribute 'group'

AttributeError:'str'对象没有属性'author'

Python问题——AttributeError: 'NoneType' object has no attribute 'append'

text AttributeError:模块'enum'没有属性'IntFlag'

返回AttributeError:'int'对象没有属性'encode'

pymysql报AttributeError: module 'pymysql' has no attribute 'connect'