NameError:未定义名称"json"
尝试导入Json,我的命令是pip install json
.
我正在Windows 8.1上工作
Trying to import Json, my command is pip install json
.
I'm working on windows 8.1
我在命令提示符中遇到的错误是
The error i'm getting in command prompt is
Could not find a version that satisfies the requirements json <from versions:>
No matching distribution found for json
.
我在pycharm上遇到的错误是
and the error i'm getting on pycharm is
NameError: name 'json' is not defined
我尝试导入numpy
,效果很好.
我也确实检查了 Pip找不到满足以下条件的要求"
和找不到满足要求<包>
I tried importing numpy
and it worked just fine .
I also did check Pip "Could not find a that satisfies the requirement"
and Could not find a version that satisfies the requirement <package>
也请参见此链接 Python 3.5 .1:NameError:未定义名称'json',并收到无法识别sudo的错误
Edit : Referred also to this link Python 3.5.1 : NameError: name 'json' is not defined and getting an error that sudo is not recognized
如果您的代码中未定义,则需要将其导入.这与Python中的 any 名称完全相同;您必须先定义一些东西,然后才能使用它.
If it's not defined in your code, you need to import it. This is exactly the same as any name in Python; you can't use something until you have defined it.
import json