gpt4 book ai didi

python - 在包含字符串和整数的列表上使用 max()

转载 作者:太空宇宙 更新时间:2023-11-04 07:17:45 24 4
gpt4 key购买 nike

<分区>

当我尝试在包含整数和字符串组合的列表上调用 max() 函数时,在 Python 2.x 中它总是返回一个字符串

例如,

#input
li = [2, 232322, 78, 'python', 77]
max(li)

#output
'python'

这背后的逻辑是什么? Python 如何比较字符串和整数?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com