在Python中,大于号(`>`)用于比较两个值,如果左边的值大于右边的值,则返回`True`,否则返回`False`。以下是使用大于号的一些示例:
x = 5y = 10使用大于号比较数字if x > y:print('x is greater than y')else:print('x is not greater than y')使用大于号比较字符串(按ASCII码值)string1 = 'apple'string2 = 'banana'if string1 > string2:print('string1 is greater than string2')else:print('string1 is not greater than string2')使用大于号比较日期对象from datetime import datedate1 = date(2021, 10, 1)date2 = date(2020, 10, 1)if date1 > date2:print('date1 is greater than date2')else:print('date1 is not greater than date2')
请注意,当比较字符串时,Python会按照ASCII码值进行比较。对于日期对象,Python会按照日期的先后顺序进行比较。

