# 示例代码:使用 Python 3 的 print 函数
# 基本用法
print("Hello, World!") # 输出: Hello, World!
# 打印多个值,用空格分隔
print("Python", "is", "awesome") # 输出: Python is awesome
# 使用 sep 参数自定义分隔符
print("Python", "is", "awesome", sep=" - ") # 输出: Python - is - awesome
# 使用 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
# 打印变量
name = "Alice"
age = 30
print("Name:", name, "Age:", age) # 输出: Name: Alice Age: 30
# 使用 f-string 格式化输出(Python 3.6+)
print(f"Name: {name}, Age: {age}") # 输出: Name: Alice, Age: 30
上一篇:python捕获异常
下一篇:python怎么调用函数
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站