登录
首页 >  文章 >  python教程

python 中的 PRINT 函数

来源:dev.to

时间:2024-07-15 11:19:10 146浏览 收藏

本篇文章给大家分享《python 中的 PRINT 函数》,覆盖了文章的常见基础知识,其实一个语言的全部知识点一篇文章是不可能说完的,但希望通过这些问题,让读者对自己的掌握程度有一定的认识(B 数),从而弥补自己的不足,更好的掌握它。

python 中的 PRINT 函数

13-07-2024

打印()函数

print()函数是一个可以让我们输出到屏幕的函数

print() 函数有三种不同的用途;

  1. 单引号 (' ')
  2. 双引号 (" ")
  3. 三引号(“””“””)------------用于多行

我们可以使用任何人输入的引用,不能在同一行中使用不同的引用

print()---------------------------#create empty line
print("jothilingam")--------------#string should print with""
print(5)------------------------#number can print without ""
print("jo""jo")--------------print without space
print("jo"+"jo")--------------print without space
answer    jojo
print("jo","jo")--------------print with space
answer     jo jo

用 f 弦打印

name = "jothi"
print(f"hello {name}")
# output : hello jothi

换行转义字符 n

print("jo\nthi")
jo
thi

print()函数的参数:

单独参数

print("jo","jo",sep="_")...................sep="" is default
answer    jo_jo
print("jo", "lingam", sep='thi')
answer     jothilingam

结束参数

print("jothi",end="lingam")
answer  jothilingam
print("jothi",end="")----------------without space
print("lingam")
answer  jothilingam
print("jothi",end=" ")----------------with space
print("lingam")
answer  jothi lingam

* 参数

print(*"jothilingam")
answer    j o t h i l i n g a m

file和flush参数,因为这些参数是允许我们处理文件的参数

今天带大家了解了的相关知识,希望对你有所帮助;关于文章的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~

声明:本文转载于:dev.to 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>