要在Python中打印內容,可以使用print()函數。以下是幾個示例:
print("Hello, World!")
name = "Alice"
print(name)
age = 25
print("My name is", name, "and I am", age, "years old.")
print("My name is {} and I am {} years old.".format(name, age))
print(f"My name is {name} and I am {age} years old.")
無論哪種方式,當代碼執行時,打印的內容將顯示在控制臺上。