Python 3.9关于输入功能的怪异行为

发布于 2025-02-02 15:15:07 字数 288 浏览 4 评论 0原文

我在最新的Pycharm IDE中使用Python 3.9。我有一个非常简单的3衬里:

a=input()
b=input()
print(b)

我输入3,然后输入4 ---但是,以某种方式未注册该值4,什么也没有打印。奇怪的是,当我在第二个输入函数中添加提示时,一切都返回正常,

a=input()
b=input("test:")
print(b)

输出将按预期返回值b。我到处都在网上看,无法解释这种奇怪的行为。到底是怎么回事?

I am using python 3.9 in the newest Pycharm ide. I have a very simple 3 liner:

a=input()
b=input()
print(b)

I input 3, enter, then 4---but somehow the value 4 is not registered, and nothing is printed. Strangely enough, when I add a prompt to the second input function, everything returns normal

a=input()
b=input("test:")
print(b)

The output returns the value b as expected. I have looked everywhere online and could not explain this odd behaviour. What is going on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

琴流音 2025-02-09 15:15:07

原来是一种pycharm设置。必须在运行/编辑配置下启用“在输出控制台中模拟终端”

Turns out to be a pycharm setting. Had to enable "emulate terminal in output console" under run/edit configurations

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文