gpt4 book ai didi

Python/Json 属性错误 : partially initialized module 'json' has no attribute

转载 作者:行者123 更新时间:2023-12-02 16:43:36 24 4
gpt4 key购买 nike

我正在运行 带有 MS Code Python 3.7 的 Windows 10

我从我的简单代码块中得到以下消息

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)

我的代码

import json

jsFile = open("myjson.json","r")

FileText = jsFile.read
jsText = json.loads(FileText)

最佳答案

当您将脚本命名为您尝试导入的模块的名称时,python 会尝试首先导入您的脚本,这会导致错误

关于Python/Json 属性错误 : partially initialized module 'json' has no attribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61043445/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com