原英文帮助文档:

input([prompt])

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. When EOF is read, EOFError is raised. Example:

>>> s = input('--> ')
--> Monty Python's Flying Circus
>>> s
"Monty Python's Flying Circus"

If the readline module was loaded, then input() will use it to provide elaborate line editing and history features.

————————(我是分割线)————————

中文解释:

input([prompt])

如果prompt参数存在,它将被写入标准输出,而不带尾随换行符。然后,该函数从输入中读取一行,将其转换为字符串(去掉尾随的换行符),并返回该行。

当读取到EOF时,将引发EOFError。例子:

>>> s = input('--> ')
--> Monty Python's Flying Circus
>>> s
"Monty Python's Flying Circus"

  关于EOFError:

exception EOFError
Raised when the input() function hits an end-of-file condition (EOF) without reading any data. (N.B.: the io.IOBase.read() and io.IOBase.readline() methods return an empty string when they hit EOF.)

  当input()函数在不读取任何数据的情况下达到文件结束条件(EOF)时引发。(注意:io.iobase.read()和io.iobase.readline()方法在到达EOF时返回空字符串。)

如果读取到readline模块, input() 将使用它来提供精细的行编辑和历史特征。

示例:

>>> input()
s
's'
>>> a = input("please input str")
please input str99
>>> a
''
>>> a = input("please input str\n")
please input str
100
>>> a
''
>>>

———————(我是分割线)————————

注意:在Python 2.x  和Python 3.x版本中input函数的区别:

所以在Python 2.x 中常见到的是raw_input() ;

原文地址:https://blog.csdn.net/suibianshen2012/article/details/51378948

————————(我是分割线)————————

参考:

1. Python 3.7.2 documentation

2. RUNOOB.COM:

https://www.runoob.com/python/python-func-input.html

https://www.runoob.com/python3/python3-func-input.html

https://www.runoob.com/w3cnote/python2-python3-raw_input-and-input.html

https://www.runoob.com/python3/python3-func-input.html

3. https://blog.csdn.net/suibianshen2012/article/details/51378948

备注:

初次编辑时间:2019年9月21日22:41:17

第一次修改时间:2019年9月22日17:03  / 添加Python3 的Input函数说明

环境:Windows 7   / Python 3.7.2

【Python】【基础知识】【内置函数】【input的使用方法】的更多相关文章

  1. 十六. Python基础(16)--内置函数-2

    十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...

  2. 十五. Python基础(15)--内置函数-1

    十五. Python基础(15)--内置函数-1 1 ● eval(), exec(), compile() 执行字符串数据类型的python代码 检测#import os 'import' in c ...

  3. python基础(15):内置函数(一)

    1. 内置函数 什么是内置函数? 就是python给你提供的,拿来直接⽤的函数,比如print,input等等,截⽌到python版本3.6.2 python⼀共提供了68个内置函数.他们就是pyth ...

  4. python基础(内置函数+文件操作+lambda)

    一.内置函数 注:查看详细猛击这里 常用内置函数代码说明: # abs绝对值 # i = abs(-123) # print(i) #返回123,绝对值 # #all,循环参数,如果每个元素为真,那么 ...

  5. Python基础:内置函数

    本文基于Python 3.6.5的标准库文档编写,罗列了英文文档中介绍的所有内建函数,并对其用法进行了简要介绍. 下图来自Python官网:展示了所有的内置函数,共计68个(14*4+12),大家可以 ...

  6. 第六篇:python基础_6 内置函数与常用模块(一)

    本篇内容 内置函数 匿名函数 re模块 time模块 random模块 os模块 sys模块 json与pickle模块 shelve模块 一. 内置函数 1.定义 内置函数又被称为工厂函数. 2.常 ...

  7. Python基础编程 内置函数

    内置函数 内置函数(一定记住并且精通) print()屏幕输出 int():pass str():pass bool():pass set(): pass list() 将一个可迭代对象转换成列表 t ...

  8. Python基础_内置函数

        Built-in Functions     abs() delattr() hash() memoryview() set() all() dict() help() min() setat ...

  9. 学习PYTHON之路, DAY 4 - PYTHON 基础 4 (内置函数)

    注:查看详细请看https://docs.python.org/3/library/functions.html#next 一 all(), any() False: 0, Noe, '', [], ...

  10. python基础(16):内置函数(二)

    1. lamda匿名函数 为了解决⼀些简单的需求⽽设计的⼀句话函数 # 计算n的n次⽅ def func(n): return n**n print(func(10)) f = lambda n: n ...

随机推荐

  1. Python字符串运算符

    下表实例变量 a 值为字符串 "Hello",b 变量值为 "Python": 操作符 描述 实例 + 字符串连接 >>>a + b 'Hel ...

  2. java常见问题 ——编辑报错1

    报错1 The method add(CatNode) in the type List<CatNode> is not applicable for the arguments (Str ...

  3. 阿里云ECS新增端口

    由于本地开多台虚拟机玩集群,发现内存有点吃不消,好奇心的驱使下,买了一台阿里云玩玩,发现外面访问不了端口. 解决: 登陆阿里云网站,进入控制台,点击云服务器ECS 进入服务器控制台,点击要选择的服务器 ...

  4. docker自动启动容器

    Docker提供了重新启动策略 来控制容器在退出时或Docker重新启动时是否自动启动.重新启动策略可确保以正确的顺序启动链接的容器.Docker建议您使用重新启动策略,并避免使用进程管理器来启动容器 ...

  5. Xshell安装教程及Xshell安装程序集组件时出错的解决方法

    部分小伙伴在安装Xshell的时候可能会遇到这个问题:“Xshell5安装程序集组件{0D7E67F6-1A6A-3A26-AF95-B8E83DDCCC3F}时出错.HRESULT0x80070BC ...

  6. fatal error C1189: #error: "Oops: min() and/or max() are defined as preprocessor macros. Define NOMINMAX macro before including any system headers!"

    1.问题描述 vs2015 使用pg数据库的C++库文件4.0.1版本libpqxx.dll,包含头文件#include "pqxx\pqxx" 出现这个错误: fatal err ...

  7. canvas基础知识点(一)

    给canvas设置宽高: canvas标签的宽高默认是300*150,是一个行内块元素 可以在canvas标签上通过width,height来设置 可以在js中给dom对象设置: mycanvas.w ...

  8. C++入门经典-例6.21-比较string字符串,比较两个字符串

    1:使用“>”.“!=”.“>=”等比较运算符可以比较两个字符串的内容.比较的方法是将两个string字符串从头开始比较每一个字符,直到出现两者不一致.比较这两个不相同的字符的字面值,得出 ...

  9. 代码优化-多态代替IF条件判断

    场景描述 在开发的场景中,常常会遇到打折的业务需求,每个用户对应的等级,他们的打折情况也是不一样的.例如普通会员打9折,青铜会员打8.5折,黄金会员打8折等等.在一般开发中最简单的就是判断用户的等级, ...

  10. group_concat() 函数 拼接字符串长度有限制

    最近,在做一个行转列的存储过程,遇到一个问题,问题如下: 我用group_concat()函数 来整合一个月每天的操作量,并将每天的操作量用CONCAT()函数拼接成 “MAX(IF(t.a = '2 ...