“import json” 在 Python 中为什么不起作用?

huangapple go评论70阅读模式
英文:

why my "import json" is not working in python

问题

我正在导入 Json 以获取数据,但此命令不起作用
我已经尝试了不同的方法,比如创建虚拟环境,但还是不起作用

在此处输入文本

帮我解决这个问题
为什么一直显示这个错误?

英文:

I am importing Json to fetch data, but this command is not working
I already did different things like creating virtual environment, but it's not working


```type here
[enter image description here](https://i.stack.imgur.com/Rz5L1.png)

HELP ME WITH THIS 
Why is this keep showing me this error 

</details>


# 答案1
**得分**: 1

你的源文件名为 `json.py`,这会覆盖内置的 `json` 模块。基本上,你的模块尝试重新导入自己,这在Python中是不允许的。要解决这个问题,只需将你的文件命名为其他名称。

<details>
<summary>英文:</summary>

Your source file is named `json.py`, which shadows the built-in `json` module. Essentially, your module tries to reimport itself, which is not allowed in Python. To fix it, just name your file something else

</details>



huangapple
  • 本文由 发表于 2023年7月20日 19:39:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76729461.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定