Python笔记——input( )和raw_input( )

来源:互联网 发布:linux elf 加壳 编辑:程序博客网 时间:2024/05/29 03:47

写了一小段Python代码,想要实现键盘终止程序。代码如下:

while True:    profit = input("input:")    if profit == "quit":        breakprint('Done')

发现并不如愿。将第二行中的函数input修改为raw_input后,则可实现循环终止。

raw_input( ): raw_input将输入作为字符串。

intput( ):  input将输入转为Python表达式。



PS:   Python 3.x版本不存在上述问题。

参考:

http://zhidao.baidu.com/link?url=a62XDI93gjJXhfW3WwgJVZjBx7WDqnoTXURQNWuWh1uKfOAuUX0ZQ7-XGQtlls_FN4ZySZmwHZJEAK-xP32JRq

http://stackoverflow.com/questions/4915361/whats-the-difference-between-raw-input-and-input-in-python3-x


0 0
原创粉丝点击