【Python】【基础知识】【内置函数】【input的使用方法】
原英文帮助文档:
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的使用方法】的更多相关文章
- 十六. Python基础(16)--内置函数-2
十六. Python基础(16)--内置函数-2 1 ● 内置函数format() Convert a value to a "formatted" representation. ...
- 十五. Python基础(15)--内置函数-1
十五. Python基础(15)--内置函数-1 1 ● eval(), exec(), compile() 执行字符串数据类型的python代码 检测#import os 'import' in c ...
- python基础(15):内置函数(一)
1. 内置函数 什么是内置函数? 就是python给你提供的,拿来直接⽤的函数,比如print,input等等,截⽌到python版本3.6.2 python⼀共提供了68个内置函数.他们就是pyth ...
- python基础(内置函数+文件操作+lambda)
一.内置函数 注:查看详细猛击这里 常用内置函数代码说明: # abs绝对值 # i = abs(-123) # print(i) #返回123,绝对值 # #all,循环参数,如果每个元素为真,那么 ...
- Python基础:内置函数
本文基于Python 3.6.5的标准库文档编写,罗列了英文文档中介绍的所有内建函数,并对其用法进行了简要介绍. 下图来自Python官网:展示了所有的内置函数,共计68个(14*4+12),大家可以 ...
- 第六篇:python基础_6 内置函数与常用模块(一)
本篇内容 内置函数 匿名函数 re模块 time模块 random模块 os模块 sys模块 json与pickle模块 shelve模块 一. 内置函数 1.定义 内置函数又被称为工厂函数. 2.常 ...
- Python基础编程 内置函数
内置函数 内置函数(一定记住并且精通) print()屏幕输出 int():pass str():pass bool():pass set(): pass list() 将一个可迭代对象转换成列表 t ...
- Python基础_内置函数
Built-in Functions abs() delattr() hash() memoryview() set() all() dict() help() min() setat ...
- 学习PYTHON之路, DAY 4 - PYTHON 基础 4 (内置函数)
注:查看详细请看https://docs.python.org/3/library/functions.html#next 一 all(), any() False: 0, Noe, '', [], ...
- python基础(16):内置函数(二)
1. lamda匿名函数 为了解决⼀些简单的需求⽽设计的⼀句话函数 # 计算n的n次⽅ def func(n): return n**n print(func(10)) f = lambda n: n ...
随机推荐
- HZOJ 20190727 T2 单(树上dp+乱搞?+乱推式子?+dfs?)
考试T2,考试时想到了40pts解法,即对于求b数组,随便瞎搞一下就oxxk,求a的话,很明显的高斯消元,但考试时不会打+没开double挂成10pts(我真sb),感觉考试策略还是不够成熟,而且感觉 ...
- BZOJ 2651 城市改建 树形DP+模拟?
题意 给一颗树,删除一条边再加一条边,使它仍为一颗树且任意两点间的距离的最大值最小. 题目数据范围描述有问题,n为1或重建不能使任意两点距离最大值变小,可以输出任意答案. 分析 删除一条边后会使它变成 ...
- 深度学习笔记(十一)网络 Inception, Xception, MobileNet, ShuffeNet, ResNeXt, SqueezeNet, EfficientNet, MixConv
1. Abstract 本文旨在简单介绍下各种轻量级网络,纳尼?!好吧,不限于轻量级 2. Introduction 2.1 Inception 在最初的版本 Inception/GoogleNet, ...
- js--BOM对象(2)
一.window对象是整个bom的核心 二.window对象的属性: history:(有关客户访问过的url信息) 方法: back() 加载 history 对象列表中的前一个URL forwar ...
- 关于vue-resource 跨域请求的异常处理方法
当你启动一个vue项目时,项目会运行在一个webpack的服务上,所以此时去访问其他端口或者是其他地址时,属于跨域请求,故会报异常. has been blocked by CORS policy: ...
- getFieldDecorator用法(三)——Table增删改
后台管理系统常用到表单的增删改,这里也做了个封装 例如:user/index.js import React from 'react' import { Card, Button, Table, Fo ...
- JavaWeb_(Hibernate框架)Hibernate中对象的三种状态
对象的三种状态 瞬时状态: 实体 没有id.没有与session关联 持久化状态: 特点:持久化状态对象的任何改变都会同步到数据库中 游离态[也称作托管态]: 实体 有id,没有与session关联 ...
- Marked
哈夫曼树 2-sat问题 线性代数基础 矩阵和行列式基础 可并堆1 可并堆2 概率与期望概念 Kruskcl重构树1 Kruskcl重构树2 匈牙利算法 带权并查集 C++参考手册 尺取法 AC自动机 ...
- AWS EC2 PV Drivers 驱动升级
问题 从2019-10-23起,我的AWS实例不断的重启(大概6个小时左右),或者连接不上(远程连接不上并PING不通IP),但控制台显示running. 分析与解决方法 通过查看dump文件,发现是 ...
- 石川es6课程---12、Promise
石川es6课程---12.Promise 一.总结 一句话总结: 用同步的方式来书写异步代码,让异步书写变的特别简单 用同步的方式来书写异步代码Promise 让异步操作写起来,像在写同步操作的流程, ...