Python读取键盘输入
来源:互联网 发布:杭州淘宝美工培训费用 编辑:程序博客网 时间:2024/05/16 12:08
Python提供了两个内置函数从标准输入读入一行文本,默认的标准输入是键盘。如下:
- raw_input
- input
raw_input函数
raw_input() 函数从标准输入读取一个行,并返回一个字符串(去掉结尾的换行符):
str = raw_input("Enter your input: ");print "Received input is : ", str
这将提示你输入任意字符串,然后在屏幕上显示相同的字符串。当我输入"Hello Python!",它的输出如下:
Enter your input: Hello PythonReceived input is : Hello Python
input函数
input() 函数和raw_input() 函数基本可以互换,但是input会假设你的输入是一个有效的Python表达式,并返回运算结果。这应该是两者的最大区别。
str = input("Enter your input: ");print "Received input is : ", str
这会产生如下的对应着输入的结果:
Enter your input: [x*5 for x in range(2,10,2)]Recieved input is : [10, 20, 30, 40]
4 0
- Python 读取键盘输入字符
- Python读取键盘输入
- Python 读取键盘输入 区别input()与raw_input()
- Python 读取键盘输入 :raw_input()和input() 函数 读取交互输入
- shell读取键盘输入
- Linux程序设计:读取键盘输入
- Python 读取键盘输入字符,多线程操作,文件操作随机处理 开发范例
- Python 模拟键盘输入
- Python 模拟键盘输入
- 用Python模拟键盘输入
- Python模拟键盘输入
- Python 模拟键盘输入
- python获取键盘输入
- python 监控键盘输入
- 用Python模拟键盘输入
- Python键盘输入的区别
- python 键盘输入总结
- python模拟键盘输入
- 设计模式六大原则(Design patterns six principles)
- 在Android中绘制圆角矩形图片
- 水仙花数(杭电2010)
- JCIP_5_01_CopyOnWriteArrayList为什么不会产生ConcurrentModificationException?
- uitabbarcontroller上的tabbaritem的图片设置
- Python读取键盘输入
- 关于iOS,Xcode的一些小技巧整理
- Java常用类库(Date类)
- cheap oakley sunglasses Abbotsford Police Department
- ray ban uk A toilet bag that can be used as fertilizer
- oakley.com Are you up to the 'Love Your River' challenge
- louis vuitton Another kind of frozen vegetables
- tn pas cher Animal House
- red bottom shoes for women Advanced Brassiere Cleansing Lessons