leet code 008:atoi 字符串转整型数

def atoi_int(n):
    import string
    l=len(n)
    stint=''
    for i in range(l):
        if n[i].isdigit():
            stint+=n[i]
    print(stint,type(stint))
    stint=int(stint)
    print(stint,type(stint))
    
st002=input('Please input your strings:')
atoi_int(st002)

Please input your strings:dsfoshefowey98r79w874923hi4uy238576
98798749234238576 
98798749234238576 

你可能感兴趣的:(Python,leet,code,leetcode,string)