在 Python(如果重要的话是 3.x)中比较两个字符(即一个字符 str
)是否定义明确?
还是我必须进行显式转换?
换句话说,就是:
'a' > 'b'
等同于:
ord('a') > ord('b')
最佳答案
不确定时,检查 docs :
Strings (instances of
str
) compare lexicographically using the numerical Unicode code points (the result of the built-in functionord()
) of their characters.
是的,行为定义明确。
关于python - 比较Python中的两个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60433868/