Python 3.0 中使用"input" , Python 2.0 中使用"raw_input"

Python 3.5:

1 #!C:\Program Files\Python35/bin

2 #-*- conding:utf-8 -*-

3 #author: Frank

4 user_input = input("please input your name:") #input 函数的使用

5 print("User input Msg:", user_input)6

7 #显示结果

8 >>>please input your name: Frank9 User input Msg: Frank

Python 2.7:

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> user_input = input("your name:") # For python2.7 , 这是错误的写法

your name:is

Traceback (most recent call last):

File "", line 1, in

File "", line 1

is

^

SyntaxError: unexpected EOF while parsing

>>> user_input = raw_input("your name:") # For python 2.7 , raw_input 是正确的.

your name: Frank

>>> print user_input

Frank

在python3.0 中, input 默认接受的都是 string

eg: 下面的代码将出错

# -*- conding:utf-8 -*-

# author: Frank

name = input("please input your name:")

age = input("please input your age:")

job = input("please input your job:")

# 这里用了一个变量Msg,多行模式

Msg = '''

Information of user Frank:%s

------------------------

Name : %s

Age : %d

Job :%s

------------End---------

''' %(name,name, age, job)

print(Msg)

结果出错:

please input your name: frank bian

please input your age:34

please input your job:it

Traceback (most recent call last):

File "", line 16, in

TypeError: %d format: a number is required, not str

input python_Python input 使用相关推荐

  1. input python_python input 详解

    解决问题: input 得到的数据到底是什么类型 多个参数接收input的输入,是怎么解包的 如果输入的个数不确定,怎么处理 要判断输入的是不是float 类型 要对输入的参数格式输出,规定参数只能是 ...

  2. SCALA Linux安装:JAVA.LANG.NUMBERFORMATEXCEPTION: FOR INPUT FOR INPUT STRING: “0X100“

    SCALA安装:JAVA.LANG.NUMBERFORMATEXCEPTION: FOR INPUT FOR INPUT STRING: "0X100" 问题描述 Linux终端输 ...

  3. raw input()和input区别

    版本差异 raw_input-->python2版本 input-->python3版本 2. 输入格式差异 就是raw_input()随便输都是字符串,而input()必须按照Pytho ...

  4. chrome浏览器中自带input样式input:-internal-autofill-selected(修改input背景色)

    实现思路1:如果不是想设置为透明色 可直接使用box-shadow input:-webkit-autofill{-webkit-box-shadow:0 0 0 1000px white inset ...

  5. 记录一下uni-app输入框input的@input事件失效问题

    今天开发中遇到一个Bug,input的@input事件竟然时而触发时而失效,先来看看我的代码: HTML: <input@input="changeNumber"type=& ...

  6. input什么意思python_python input是什么意思,_Python_ 少侠科技

    详细内容 Python是一种解释型.面向对象.动态数据类型的高级程序设计语言.Python由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年.像Perl语言一样, ...

  7. linux的自定义input,Linux Input子系统之第一篇(input_dev/input_handle/input_handler)

    Input子系统是linux kernel中与部分外围器件驱动联系比较紧密的模块,常用于Sensor,TP(touch panel),power key等器件的驱动.这类模块有个共同特点:字符设备,且 ...

  8. input core input.c (1)

    drivers/input/input.c 就是所谓的input的核心程序. 分析这个文件,先从input_init开始. 1: static int __init input_init(void) ...

  9. axios get的parameter /eg /url+?input=6^input=8

    2019独角兽企业重金招聘Python工程师标准>>> eg 解决办法 let multis=[123,144] let url = '/api/Product/off?' mult ...

最新文章

  1. QT的Q3DBars类的使用
  2. Linux连接状态为syn_recv,linux 服务器 syn*** 大量SYN_RECV状态处理
  3. 深度学习经典算法 | 蚁群算法解析
  4. 蓝桥杯BASIC-28 基础练习 Huffuman树
  5. 2022.9.19-9.25 AI行业周刊(第116期):告别
  6. router走差分_route
  7. 因为制作爬虫程序,我收到了警告
  8. 从Garmin USB中读取GPS数据(串口实现)
  9. 功率曲线k值_一种基于DTW的改进K-means的日负荷曲线聚类方法技术
  10. 【MTK 6737】Modem编译
  11. 新版悟能口罩预约小程序源码V1.1.1
  12. 建筑行业现行相关税收政策及优惠措施汇编
  13. Docker部署Overleaf包含中文字体与全套texlive镜像
  14. 算法(第4版) 编写一个静态方法lg(),接受一个整型参数N,返回不大于log2N的最大整数。(不要使用Math库)
  15. python绘制对数函数_python中如何画对数函数图?
  16. javascript交互性设计
  17. 海康设备接入EasyCVR,出现告警信息缺失且不同步该如何解决?
  18. C#winform 经典小游戏贪吃蛇V1.0(一)
  19. 如何安装内存条(图文教程)
  20. 回归模型的score得分为负_SPSS中 回归 B值为负数什么意思

热门文章

  1. 4-Qt6控制台项目信号与槽
  2. Carplay Hub技术
  3. 如何把class里的vector结构体memcpy出来_面试官:请说出线程安全的 ArrayList 有哪些,除了Vector...
  4. wifi共享大师电脑版_Wifi分析助手PC版-Wifi分析助手电脑版下载 v7.2.2-
  5. .bash_profile 写入时间格式YYYY-MM-DD HH24:MI:SS 时报错 not a valid identifier
  6. solidworks热分析_solidworks解决管道流体问题,原来可以如此轻松
  7. linux centos lamp,Centos下搭建LAMP
  8. 构造函数与折构函数(c++细节篇五)
  9. elasticsearch入门hello world (macos)【一】下载运行
  10. 信息系统项目管理师优秀论文:沟通与干系人管理