compare two python strings that contain numbers

前端 未结 5 1510
礼貌的吻别
礼貌的吻别 2020-12-19 11:29

UPDATE: I should have specified this sooner, but not all of the names are simply floats. For example, some of them are \"prefixed\" with \"YT\". So for example\" YT1.1. so,

5条回答
  •  一整个雨季
    2020-12-19 12:14

    If you know they are real numbers [*] , simply:

    >>> float(s1) > float(s2)
    True
    

    [*] Otherwise, be ready to handle a raised ValueError.

提交回复
热议问题