python程序设计基础(三)
上次讲诉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新学苑原创,部分图片文字来自网络,如有侵权请联系。
专票丢了怎么办?1增值税专用发票如何查询真伪?答尊敬的纳税人,您可登陆国家税务总局全国增值税发票查验平台查询真伪,具体操作可查询范围等请以网站中发票查验说明为准。2购买方丢失了增值税专用发票,是否
商标近似还能注册吗在注册商标的时候,很容易遇到近似商标的情况,那么这时候问题就来了。商标近似还能注册吗,下面企帮帮小编就来给大家讲讲吧。一近似商标能注册吗通常上,如果一个新设计的商标与注册的商标相似
公司注册经营范围有哪些特殊规定经营范围是指国家允许企业生产和经营的商品类别品种及服务项目,反映企业业务活动的内容和生产经营方向,是企业业务活动范围的法律界限,体现企业民事权利能力和行为能力的核心内容。那么公司注
郑渊洁维权两年成功,舒克贝塔公司被要求改名现代快报8月24日消息,刚过去的这个周末,童话大王郑渊洁来了趟南京,他心情大好,长达两年的舒克贝塔名称之争终于一锤落定。两年前,郑渊洁向南京市市场监督管理局举报,指出南京舒克贝塔宠
商标近似还能注册吗在注册商标的时候,很容易遇到近似商标的情况,那么这时候问题就来了。商标近似还能注册吗,下面企帮帮小编就来给大家讲讲吧。一近似商标能注册吗通常上,如果一个新设计的商标与注册的商标相似
英雄联盟手游还未公测就开始转向赛事化,急于求成可能适得其反不知道大家有没有发现,近期各个直播平台的lol板块中的置顶直播间,除了LPL的赛事直播以外下面就是英雄联盟手游的赛事直播,这种超前的赛事推送无异于会引发游戏圈新一轮的竞争。60以上
人类高质量男性直播求偶?引起全网热议相信大家在前段时间的短视频平台上都看到了一个自称为人类高质量男性的人所发的求偶视频。视频内的大哥梳着锃光瓦亮的油头,脸上抹的特别白,脸颊上还带有腮红,用非常奇怪的语调夹着嗓子介绍着
纯欲天花板竟然要和国服守约solo,输了直播卸妆?近期越来越多的主播与美女网红小姐姐开启了联动模式,一方面是希望能够通过这种联动获得更多的支持与更多的粉丝,其次这种节目效果也是观众们非常喜欢的。此次联动的两位主播分别是国服百里六尾
知情人爆料Theshy将于10号重回赛场,FPX输掉比赛Bo或将回归今年的夏季赛LPL的每一支战队都带有很大的不确定性,这也让每一场比赛的看点拉满,因为谁在赛前也不确定哪一支战队能够赢下比赛。这就导致我们熟知的部分老牌强队在夏季赛出现了连败的情况,
爱情的见证?一鹿彤行商标已被注册关晓彤为鹿晗庆祝31岁生日的消息近日再次引发了全网热议二人又是送玫瑰花又是喝酒庆祝网友也是直呼一鹿彤行的组合让人在线嗑糖然而,也有细心的网友发现二人的CP名称一鹿彤行已经被申请注册
私募基金老兵待解商标缺失难题作为中国私募股权投资界拓荒者之一,曾供职摩根士丹利KKR中国等世界一流投资机构20余年的刘海峰,是名副其实的私募基金老兵。2017年,他从KKR中国离职后创建了德弘资本有限公司(D