Myridium
0
Q:

isdigit python

s='12'
s.isdigit()#returns True
3
 txt = "50800"

x = txt.isdigit()

print(x) 
0
Non-zero integer ( x > 0 )	Argument is a numeric character.
Zero (0)	Argument is not a numeric character.
1
string.isdigit() how to remove a integer from a string
1
>>> my_list= ['image101.jpg', 'image2.jpg', 'image1.jpg']
>>> my_list.sort(key=lambda x: int(''.join(filter(str.isdigit, x))))
>>> my_list
['image1.jpg', 'image2.jpg', 'image101.jpg']
0
from natsort import natsorted
my_list = ['image101.jpg', 'image2.jpg', 'image1.jpg']
natsorted(my_list)
0
>>> ''.join(filter(str.isdigit, 'image101.jpg'))
'101'
>>> int(''.join(filter(str.isdigit, 'image101.jpg')))
101
0

New to Communities?

Join the community