python 中的 PRINT 函数

当前位置: 电视猫 > php教程>
电视猫时间: 2023-11-30 15:00:00

  python 中的 PRINT 函数

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参数,因为这些参数是允许我们处理文件的参数

以上就是python 中的 PRINT 函数的详细内容,更多请关注php中文网其它相关文章!

最新电视剧
热门电视剧
影视资讯
最新剧情排行榜
最新电视剧剧情