1、字符串纯数字

s='123'
t='234'
if s>t:
    print("s>t")
else:
    print("s<t")



D:\study\python\test\venv\Scripts\python.exe D:/study/python/test/dd.py
s<t

 

2、字符串数字+字母

按首字母进行比大小

s='a123'
t='b23'
if s>t:
    print("s>t")
else:
    print("s<t")

D:\study\python\test\venv\Scripts\python.exe D:/study/python/test/dd.py
s<t
s='c123'
t='b23'
if s>t:
    print("s>t")
else:
    print("s<t")


D:\study\python\test\venv\Scripts\python.exe D:/study/python/test/dd.py
s>t

 

3、字符串字母

s='cddd'
t='bggg'
if s>t:
    print("s>t")
else:
    print("s<t")


D:\study\python\test\venv\Scripts\python.exe D:/study/python/test/dd.py
s>t

 

相关文章:

  • 2021-10-14
  • 2022-12-23
  • 2022-12-23
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-22
  • 2022-12-23
  • 2022-01-28
  • 2021-10-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案