python - Pycharm 中的 """input().split() in loop"""问题

标签 python python-3.x ubuntu terminal pycharm

n, m, k, r = tuple([int(i) for i in input().split()])

roads = []

for road in range(m):
    t = tuple(list(map(int, input().split())))
    roads.append(t)

print(roads)
我的输入是:
6 6 2 6
0 1
1 2
2 3
3 4
4 1
3 5
当我使用上述输入运行上述代码时,我的程序在我的 Ubuntu 终端上运行良好,输出如下:
[(0, 1), (1, 2), (2, 3), (3, 4), (4, 1), (3, 5)]
但是,当我在 Pycharm 上使用相同的输入运行相同的代码时,它可以正常工作,但输出不合逻辑:
[(), (0, 1), (), (1, 2), (), (2, 3)]
当我在我的 Ubuntu Pycharm 环境中进行调试时,它也很理想。但是当我运行 codem 时,它会输出不合逻辑的输出。
此外,当我像这样添加另外两个 print()-s 时:
n, m, k, r = tuple([int(i) for i in input().split()])

print()

roads = []

for road in range(m):
    t = tuple(list(map(int, input().split())))
    print()
    roads.append(t)


print(roads)
在这种情况下,一切都很好。
为什么?有什么事?

最佳答案

friend ,我想,我找到了答案。这是与 Pycharm 环境相关的问题。尝试启用“终端仿真”。
打开运行配置并切换此复选框:
enter image description here

关于python - Pycharm 中的 """input().split() in loop"""问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72255982/

相关文章:

linux - 使安装错误 'nothing to be done'

c# - ASP.NET Core 在 Linux 上的 Visual Studio Code 中调试时修改 View

python - 如何在创建目录时显示消息?

python-3.x - python : Unable to call function when in while loop

python - Pytesseract : Error opening data file\\Program Files (x86)\\Tesseract-OCR\\en. 训练数据

python-3.x - 由于 python 版本,运行 PySpark DataProc 作业时出错

python - 局部变量如何与 Python 闭包一起使用?

svn - 从 Eclipse 访问 SVN 存储库(位于另一台 ubuntu 机器中)

python - 如何在Windows中使用Python播放Mp3文件?

python - 这个 Python 登录实际上是不安全的吗?