小编Gra*_*ray的帖子

无法比较Python 3.2中的输入字符串

我在Python中遇到了一个非常奇怪的问题.这两个似乎没有帮助:

在Python中验证用户输入字符串以及在python中比较字符串的最快方法

我编写了以下小程序test.py:

import sys
while True:
    print("\n")
    print("Type exit to exit: ")

    inputvar = str(input())
    print("Input: "+inputvar)

    if inputvar == 'exit':
        print("Exiting!")
        sys.exit("\n\nProgram quit.")
    else:
        print("Still here")
Run Code Online (Sandbox Code Playgroud)

当前版本似乎没有退出exit,'exit'"exit".使用input()str(input())不是似乎没有区别,使用isin代替==也没有任何区别.

我在Windows 7上使用Python 3.2.

python input python-3.x python-3.2

4
推荐指数
1
解决办法
2546
查看次数

标签 统计

input ×1

python ×1

python-3.2 ×1

python-3.x ×1