开发者

different results in IDLE and Windows console

I write this simple bit of code (Python 3.2 on Win32):

def main():
    decision = input('¿Send mail? (y/n): ')
    if decision == "y":
        sender()
        print("Mail sent.")
    else:
        print("Cancelled.开发者_开发知识库")
    input()

def sender():
    print("In sender ... ")
    pass

main()

and it works as expected in IDLE, but in the Windows console it surprisingly says 'cancelled' when you choose 'y'.

Now this makes no sense to me, Can you please help me see what's wrong?


I suggest you read the definition of input(). It is not recommended for general user input as it expects syntactically valid Python code and eval()s it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜