Python 3.7 input()不起作用,但是raw_input起作用 [英] Python 3.7 input() doesnt work but raw_input does

查看:40
本文介绍了Python 3.7 input()不起作用,但是raw_input起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这里是经典的初学者问题...我一直在尝试在各种文本编辑器(如VSCode和Atom)上使用Python,但它们似乎都不起作用(安装python 3.7之后).如果我请求一个简单的输入,则程序会崩溃,将输入标记为未定义,但是由于某些原因,当我使用raw_input()时,它就可以正常工作.但是,在Python 3中将raw_input()更改为input(),为什么这一直发生在我身上?

So classic beginner problem here... Ive been trying to use Python on various text editors like VSCode and Atom and none of them seem to work (After installing python 3.7). If I ask for a simple input the program crashes labelling the input as undefined, but when I use raw_input() it works just fine for some reason. However, raw_input() was changed to input() in Python 3 so why does this keep happening to me?

推荐答案

您需要使用虚拟环境.由于您在Mac上运行,因此建议您使用Python的 Anaconda 发行版.说明位于此处.这简化了制作虚拟环境的过程.就像 conda create -n myenv python = 3.6 一样简单,并且更详细的说明位于

You need to be using virtual environments. Since you're running on a Mac I would suggest you use the Anaconda distribution of Python. Instructions are here. This simplifies the process of making virtual environments. It's as easy as conda create -n myenv python=3.6 and more detailed instructions are found here. Once conda is installed you can use commands like conda install scipyto install python packages. Once you have virtual environments installed and activated your command should work. Try it in the python 3.6 environment.

这篇关于Python 3.7 input()不起作用,但是raw_input起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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