Extracting only characters from a string in Python

前端 未结 7 1195
后悔当初
后悔当初 2020-12-08 07:01

In Python, I want to extract only the characters from a string.

Consider I have the following string,

input = \"{(\'players\',): 24, (\'year\',): 28         


        
7条回答
  •  孤街浪徒
    2020-12-08 07:54

    Or if you want all characters regardless of words or empty spaces

        a = "Some57 996S/tr::--!!ing"
        q = ""
        for i in a:
            if i.isalpha():
                q = "".join([q,i])
    

    print q 'SomeString'

提交回复
热议问题