网站首页 > 技术文章 正文
上次讲诉python的常见内置对象及其简单应用。和电脑进行交互也需要“沟通”。也就是说,你需要给电脑你的指令,然后,根据指令返回结果,得到你想知道的,所以今天讲述输入和输出。
输入。只需要input()内置函数,括号里可以填写提示用户输入的内容、格式等。
输出。输出要求不一样,对应输出方式也存在差异,总共来说有表达式语句、print()函数、文件输出、str.format()函数、repr()或str()。
表达式语句
一般在交互模式下,转换格式是使用。
Print()函数
print可以打印具体的变量也可以是变量名所对应的值。当输出对象有多个时,默认分隔符为空格,也可以根据需求更改。对象输出完成后,默认的为换行,也是可以更改的。
文件输出
文件输出后续详细讲诉。
repr()与str()
都将输出的值转化为字符串,不同的是str返回用户易读,而repr()返回解释器易读的形式。
邮政创新工作室实践项目“面邮优店”:主打深夜泡面、代取快递等服务,面向重邮各寝室楼栋,超快速送达,让同学们体验到足不出楼就能吃到泡面,拿到快递的愉悦觉。
英文翻译
Last time I talked about the common built-in objects of python and their simple applications. Interaction with a computer also requires "communication." In other words, you need to give the computer your instructions, and then return the results according to the instructions, and get what you want to know, so today I will talk about input and output.
enter. Only the input() built-in function is required, and the content and format that prompt the user to input can be filled in the parentheses.
Output. The output requirements are different, and the corresponding output methods are also different. In total, there are expression statements, print() function, file output, str.format() function, repr() or str().
Expression statement, generally in interactive mode, the conversion format is used.
Print() function, print can print the specific variable or the value corresponding to the variable name.
When there are multiple output objects, the default separator is a space, which can also be changed according to requirements. After the object is output, the default is line break, which can also be changed.
The file output will be discussed in detail later.
str.format() function. Simple understanding is one-to-one correspondence. Parameter substitution, position substitution, keyword parameter substitution, or consistent use. Str indicates that the previous parameter is in the form of a string.
Both repr() and str() convert the output value into a string. The difference is that str returns a user-readable form, while repr() returns a form that is easy to read by the interpreter.
The postal innovation studio practice project "Mianyou Youdian": Mainly provides services such as late-night instant noodles and express delivery. It is delivered to the dormitories and buildings of Chongyu, so that students can experience it without leaving the building. Instant noodles, the pleasure of getting express delivery.
参考资料:菜鸟教程
翻译:Google翻译
本文由LearningYard新学苑原创,部分图片文字来自网络,如有侵权请联系。
猜你喜欢
- 2024-09-18 ChuanhuChatGPT:LLM提供了一个轻快好用的Web图形界面
- 2024-09-18 真实标书查重系统中的技术复杂度(招标文件查重率)
- 2024-09-18 八悦文摘(五)—MathType内容初识(mathtype48)
- 2024-09-18 Markdown 教程(Markdown教程)
- 2024-09-18 如何在微信公众号中编辑出漂亮的数学公式?
- 2024-09-18 通过geogebra实现LATEX数学公式编辑,数学电子版笔记的好帮手!
- 2024-09-18 【干货】LaTeX超详细使用指南!附安装包
- 2024-09-18 MathType公式转换LaTeX代码(mathtype转换为latex)
- 2024-09-18 一道改编自课本的压轴题,一题多解,一题多变,初三系列153
- 2024-09-18 新手学Latex(小学)-04(换行)(latex学起来快吗)
- 1513℃桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具
- 556℃Dify工具使用全场景:dify-sandbox沙盒的原理(源码篇·第2期)
- 505℃MySQL service启动脚本浅析(r12笔记第59天)
- 484℃服务器异常重启,导致mysql启动失败,问题解决过程记录
- 482℃启用MySQL查询缓存(mysql8.0查询缓存)
- 462℃「赵强老师」MySQL的闪回(赵强iso是哪个大学毕业的)
- 442℃mysql服务怎么启动和关闭?(mysql服务怎么启动和关闭)
- 439℃MySQL server PID file could not be found!失败
- 最近发表
- 标签列表
-
- c++中::是什么意思 (83)
- 标签用于 (65)
- 主键只能有一个吗 (66)
- c#console.writeline不显示 (75)
- pythoncase语句 (81)
- es6includes (73)
- windowsscripthost (67)
- apt-getinstall-y (86)
- node_modules怎么生成 (76)
- c++int转char (75)
- static函数和普通函数 (76)
- el-date-picker开始日期早于结束日期 (70)
- js判断是否是json字符串 (67)
- checkout-b (67)
- c语言min函数头文件 (68)
- asynccallback (71)
- localstorage.removeitem (74)
- vector线程安全吗 (70)
- & (66)
- java (73)
- js数组插入 (83)
- mac安装java (72)
- eacces (67)
- 查看mysql是否启动 (70)
- 无效的列索引 (74)