首页 > 解决方案 > Python 输入函数在 VS Code 中不起作用

问题描述

    balance = 100
    print('Current Balance: ', balance)
    while balance > 0:
        print('1. WITHDRAW')
        print('2. DEPOSIT')
        choice = input("Select an option... ")
        if (choice == 1):
            print('1')
        elif (choice == 2):
            print('2')
        else:
            print('test')

当我使用代码运行器扩展程序运行代码时,代码会显示在终端中,但是当它到达输入函数时,它会冻结,就像它要求我输入一些数据一样,但是我不能输入数字或字母。

这是终端显示的...

[Running] python -u "c:\Users\bowen\Desktop\CSE 120\PROJECT 3\main.py"
Current Balance:  100
1. WITHDRAW
2. DEPOSIT
Select an option... 

标签: pythonvisual-studio-codeinputterminalvscode-code-runner

解决方案


Code Runner在 OUTPUT 中显示结果,默认情况下不接受输入。添加

"code-runner.runInTerminal": true

在 Settings.json 中,然后您可以输入数据。


推荐阅读