元组、列表也能比较大小


#2个元组、2个列表 比较大小
if ('3','2') < ('a','b'):
print("TRUE")

if (ord('3'), ord('2')) < (ord('a'), ord('b')):
print("TRUE")

print(ord('a') - ord('3'))
print(ord('b') - ord('2'))


if ['3','2'] < ['a','b']:
print("TRUE")

if [3, 2] < [ord('a'), ord('b')]:
print("TRUE")


输出:

TRUE
TRUE
46
48
TRUE
TRUE

posted @ 2020-05-23 09:46  戒而定,定而慧  阅读(1403)  评论(0编辑  收藏  举报