Python的print函數可以接受多個參數,通過將這些參數用逗號分隔來輸出多個值。這樣可以在一行中輸出多個值,提高代碼的可讀性和效率。以下是一些使用print參數的技巧:
name = "Alice"
age = 25
print("Name:", name, "Age:", age)
print("Hello", end=", ")
print("World", end="!")
print("a", "b", "c", sep=", ")
name = "Alice"
age = 25
print("Name: {}, Age: {}".format(name, age))
通過合理地使用print參數,可以使代碼更加清晰和高效。