string to float helper
This commit is contained in:
1 parent
856d0e0aa3
commit
1f16808002
1 file changed
+4
@@ -78,6 +78,10 @@ def tryInt(s):
|
|||||||
try: return int(s)
|
try: return int(s)
|
||||||
except: return s
|
except: return s
|
||||||
|
|
||||||
|
def tryFloat(s):
|
||||||
|
try: return float(s) if '.' in s else tryInt(s)
|
||||||
|
except: return s
|
||||||
|
|
||||||
def natsortKey(s):
|
def natsortKey(s):
|
||||||
return map(tryInt, re.findall(r'(\d+|\D+)', s))
|
return map(tryInt, re.findall(r'(\d+|\D+)', s))
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user