博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
print函数python_带有结束参数的Python print()函数
阅读量:2531 次
发布时间:2019-05-11

本文共 1695 字,大约阅读时间需要 5 分钟。

print函数python

print()函数 (print() function)

print() function is used to print message on the screen.

print()函数用于在屏幕上打印消息。

Example:

例:

# python print() function example# printing textprint("Hello world!")print("Hello world!")print("I\'m fine!")# printing variable's valuesa = 10b = 10.23c = "Hello"print(a)print(b)print(c)# printing text with variable's valuesprint("Value of a = ", a)print("Value of b = ", b)print("Value of c = ", c)

Output

输出量

Hello world!Hello world!I'm fine!1010.23HelloValue of a =  10Value of b =  10.23Value of c =  Hello

See the output of the above program, print() function is ending with a newline and the result of the next print() function is printing in the newline (next line).

参见上面程序的输出, print()函数以换行符结尾,下一个print()函数的结果在换行符(下一行)中打印

带有结束参数的print()函数 (print() function with end parameter)

end is an optional parameter in and its default value is '\n' which means print() ends with a newline. We can specify any character/string as an ending character of the print() function.

end是的可选参数,其默认值为'\ n' ,这意味着print()以换行符结尾 。 我们可以指定任何字符/字符串作为print()函数的结束字符。

Example:

例:

# python print() function with end parameter example# ends with a spaceprint("Hello friends how are you?", end = ' ')# ends with hash ('#') characterprint("I am fine!", end ='#')print() # prints new line# ends with nil (i.e. no end character)print("ABC", end='')print("PQR", end='\n') # ends with a new line# ends with stringsprint("This is line 1.", end='[END]\n')print("This is line 2.", end='[END]\n')print("This is line 3.", end='[END]\n')

Output

输出量

Hello friends how are you? I am fine!#ABCPQRThis is line 1.[END]This is line 2.[END]This is line 3.[END]

Recommended posts

推荐的帖子

翻译自:

print函数python

转载地址:http://dxtzd.baihongyu.com/

你可能感兴趣的文章
ZT:Linux上安装JDK,最准确
查看>>
LimeJS指南3
查看>>
关于C++ const成员的一些细节
查看>>
《代码大全》学习摘要(五)软件构建中的设计(下)
查看>>
C#检测驱动是否安装的问题
查看>>
web-4. 装饰页面的图像
查看>>
微信测试账户
查看>>
Android ListView上拉获取下一页
查看>>
算法练习题
查看>>
学习使用Django一 安装虚拟环境
查看>>
Hibernate视频学习笔记(8)Lazy策略
查看>>
CSS3 结构性伪类选择器(1)
查看>>
IOS 杂笔-14(被人遗忘的owner)
查看>>
自动测试用工具
查看>>
前端基础之BOM和DOM
查看>>
[T-ARA/筷子兄弟][Little Apple]
查看>>
编译Libgdiplus遇到的问题
查看>>
【NOIP 模拟赛】Evensgn 剪树枝 树形dp
查看>>
java学习笔记④MySql数据库--01/02 database table 数据的增删改
查看>>
两台电脑如何实现共享文件
查看>>