python之input(), raw_input()
input(): 要求输入合法的python表达式, 例如字串需要加"", 四则运算会自动计算.
raw_input():所有输入视作字串
>>> val=input("input your expression: ")
input your expression: "what is your name"
>>> print "your input value is: "+val
your input value is: what is your name
>>> val=input("input your expression: ")
input your expression: 3*4+5
>>> print "your input value is: "+str(val)
your input value is: 17
注意: python中的"+"只能连接2个字串,或者作加号. 其它类型必须先转换...否则:
>>> print "your input value is: "+val
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: cannot concatenate 'str' and 'int' objects
python之input(), raw_input()的更多相关文章
- python使用input()来接受字符串时一直报错“xxx is not defined”
报错信息: “Please input your guess: gussTraceback (most recent call last): File "coinGuessGame.py& ...
- Python - 3. Input and Output
from:http://interactivepython.org/courselib/static/pythonds/Introduction/InputandOutput.html Input a ...
- qpython 读入数据问题: EOF error with input / raw_input
直接使用input会报错 EOF error with input / raw_input 原因是在qpy里console mode 命令行模式不是完全和pc上的命令行一致,所以input和raw_i ...
- 【Python笔记】2020年7月30日练习【python用input函数输入一个列表】
练习课题链接:廖雪峰-Python教程-高级特性-迭代 学习记录: 1.Python当中类似于 三目运算符 的应用 2.Python用input函数输入一个列表 代码实例:对用户输入的一组数字转化成l ...
- python 中 input 和 raw_input 的区别
input会假设输入的信息是合法的python表达式,例如,输入一个人名,Diesel,input会认为这是一个变量,必须加上引号,比如“Diesel”: 而raw_input会把所有的输入当作原始数 ...
- python中input()和raw_input()的区别
两者均是python的内置函数,通过读取控制台的输入与用户实现交互.raw_input:将所有输入作为字符串看待,不管用户输入什么类型的都会转变成字符串. raw的 ...
- python中input和raw_input函数
python input() 相等于 eval(raw_input(prompt)) ,用来获取控制台的输入. raw_input() 将所有输入作为字符串看待,返回字符串类型.而 input() 在 ...
- Python中的raw_input()和input()
raw_input()和input()都是python中的内建函数,用于读取控制台用户的输入,但有所区别: [nr@localhost conf]$ python Python 2.7.5 (defa ...
- python中input()与raw_input()的区别到底是啥?-----marsggbo原创作品为你解答
首先先给出总结:input () = int(raw_input()) 有图有真相!!! 先看看input的例子: 可见用input键入得到int类型的数据,那如果输入一些非int类型的会怎么样呢? ...
随机推荐
- oracle冷备份
windows环境下Oracle数据库冷备份和恢复 1.点击开始菜单的“运行”,输入sqlplus/nolog 2.在弹出的命令行窗口以sysdba身份登陆,要输入:系统用户名/登陆密码@数据库实例名 ...
- MySQL 中随机抽样:order by rand limit 的替代方案
最近由于需要大概研究了一下MYSQL的随机抽取实现方法.举个例子,要从tablename表中随机提取一条记录,大家一般的写法就是:SELECT * FROM tablename ORDER BY RA ...
- Event Handling in Spring
Spring内置的event有 1.ContextRefreshedEvent This event is published when the ApplicationContext is eithe ...
- poj 1390 动态规划
思路: 黑书的例题 #include<iostream> #include<cstring> #include<algorithm> #include<cma ...
- 【转】ASP.NET 高效分页存储过程
代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-- ...
- Table of Contents - ActiveMQ
Getting Started ActiveMQ 的安装 Hello World Configuring Standard ActiveMQ Components Connecting to Acti ...
- Socket 两平台互相 通信 .NET
两个平台互相通信,对方发送数据过来,我方接收数据,对数据进行处理后发送结果给对方,对方进行相应的操作. 首页,我方开启服务监听: Socket socket = new Socket(AddressF ...
- C#垃圾回收机制
C#属于托管的面相对象的语言,内存回收机制就是一个代表, C#有一套类似"全自动"的垃圾回收机制,也就是虚拟机会自动来判断执行内存的回收, 我们一般常用的Dispose(),Usi ...
- CSS之全屏背景图
吐槽啦:Yeah 明天就是国庆了o(* ̄▽ ̄*)o!哈哈,提前祝福各位园友国庆快乐.假期愉快.生活美满.天天开心!国庆我要回家一趟,把一些不用的东西带回家,走访一下亲朋好友,在家打几天酱油~~~ 言 ...
- C#完全无客户端访问Oracle
网上太多的C#无客户端访问oracle案例,经我测试无一成功,特将我在oracle官网上和自己琢磨总结,终于成功,废话不多说,直接上项目. 一,准备条件 (由于我这里是用的控制台程序来测试的,所以将上 ...