NameError:未定义名称"json" [英] NameError: name 'json' is not defined

查看:160
本文介绍了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

这篇关于NameError:未定义名称"json"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆