# 示例代码:print在Python中的用法
# 最简单的用法,打印一个字符串
print("Hello, World!") # 输出: Hello, World!
# 打印多个值,使用逗号分隔
print("Name:", "Alice", "Age:", 30) # 输出: Name: Alice Age: 30
# 使用sep参数指定分隔符,默认是空格
print("apple", "banana", "cherry", sep=", ") # 输出: apple, banana, cherry
# 使用end参数指定结束符,默认是换行符\n
print("This is the first line", end=" ")
print("This is still the first line") # 输出: This is the first line This is still the first line
# 打印变量的值
x = 10
y = 20
print("x =", x, "and y =", y) # 输出: x = 10 and y = 20
# 使用f-string格式化输出
name = "Bob"
age = 25
print(f"Name: {name}, Age: {age}") # 输出: Name: Bob, Age: 25
print() 函数用于将指定的内容输出到控制台。print(),它们会用空格分隔后输出。sep 参数可以自定义输出内容之间的分隔符。end 参数可以自定义每条输出的结尾字符,默认是换行符 \n。上一篇:python upper
下一篇:python 随机整数
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站