是的,Python 的 print() 函数可以根据条件进行输出。你可以在 print() 函数中使用条件表达式(如 if 语句)来实现这个功能。下面是一个简单的示例:
age = 18
if age >= 18:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")
在这个示例中,我们首先定义了一个变量 age,然后使用 if 语句检查 age 是否大于等于 18。如果满足条件,我们使用 print() 函数输出 “You are eligible to vote.”,否则输出 “You are not eligible to vote.”。