[英]Python/Json AttributeError: partially initialized module 'json' has no attribute
I am running Windows 10 with MS Code Python 3.7我正在使用 MS 代码 Python 3.7 运行 Windows 10
I get the following message from my simple code block我从我的简单代码块中收到以下消息
Traceback (most recent call last):
回溯(最近一次通话最后):
File "c:/Users/marke/OneDrive/Desktop/Python Tutorial/json.py", line 1, in module import json File "c:\Users\marke\OneDrive\Desktop\Python Tutorial\json.py", line 6, in jsText = json.loads(FileText) AttributeError: partially initialized module 'json' has no attribute 'loads' (most likely due to a circular import)文件“c:/Users/marke/OneDrive/Desktop/Python Tutorial/json.py”,第 1 行,在模块导入 json 文件“c:\Users\marke\OneDrive\Desktop\Python Tutorial\json.py”,行6、在jsText = json.loads(FileText) AttributeError: partial initialized module 'json' has no attribute 'loads' (很可能是由于循环导入)
My code我的代码
import json
jsFile = open("myjson.json","r")
FileText = jsFile.read
jsText = json.loads(FileText)
When you name your script the name of the module you try to import, python tries to imports your script first, which results in the Error当您将脚本命名为您尝试导入的模块的名称时,python 会首先尝试导入您的脚本,这会导致错误
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.