# print在Python中的基本用法
# 1. 打印字符串
print("Hello, World!") # 输出: Hello, World!
# 2. 打印变量
name = "Alice"
print(name) # 输出: Alice
# 3. 打印多个值,使用逗号分隔
age = 30
print("Name:", name, "Age:", age) # 输出: Name: Alice Age: 30
# 4. 使用sep参数指定分隔符
print("apple", "banana", "cherry", sep=", ") # 输出: apple, banana, cherry
# 5. 使用end参数指定行尾字符(默认是换行)
print("Hello,", end=" ")
print("World!") # 输出: Hello, World!
# 6. 打印格式化字符串 (f-string)
score = 95
print(f"Your score is {score}") # 输出: Your score is 95
上一篇:python 爬虫
下一篇:python字符串
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站