我的程序在pythonshell中工作,但不';在cmd.exe中运行时,无法识别我的输入

我的程序在pythonshell中工作,但不';在cmd.exe中运行时,无法识别我的输入,python,string,input,exe,Python,String,Input,Exe,嘿,我是个新手,不知道为什么我要在cmd.exe中运行我的代码 但是,当我在其中运行脚本时,它无法识别我输入的正确密码。不过,当我在pythonshell中运行它时,它工作得很好 任何答案或帮助我指出我需要学习的正确方向都是非常好的 secret_info=["Whatmough","Graham","NOOB"] password="1234" tries=0 locked = 1 def cracker(): attempt=input("Type your Password: "

嘿,我是个新手,不知道为什么我要在cmd.exe中运行我的代码

但是,当我在其中运行脚本时,它无法识别我输入的正确密码。不过,当我在pythonshell中运行它时,它工作得很好

任何答案或帮助我指出我需要学习的正确方向都是非常好的

secret_info=["Whatmough","Graham","NOOB"]
password="1234"
tries=0
locked = 1

def cracker():
    attempt=input("Type your Password: ")

    return attempt

def checker():
    global locked, tries
    if cracker() == password:
         locked = 0
    else:
        tries = tries + 1


while 3 > tries and locked==1:
    checker()
    if locked == 0:
        print(secret_info)
    if tries == 3:
        secret_info=0
        print("Self Distructed! Your secret info is now:", secret_info)

原因是
cmd
将回车(
'\r'
)添加到输入字符串中

如果您尝试打印
repr(尝试)
,则可以看到
“\r”

要删除该回车符,可以使用
str.strip()
str.rstrip(“\r”)


你是怎么运行的?谢谢你的回答!但它现在正在崩溃。是否有其他的东西,我将不得不改变它在cmd的工作?
attempt = input("Type your Password: ").rstrip("\r")