📜  str 删除字母除外 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:55.588000             🧑  作者: Mango

代码示例1
#take user input
String1 = input('Enter the String :')
#initialize empty String
String2 = ''
for i in String1:
    #check for alphabets
    if (ord(i) >= 65 and ord(i) <= 90) or (ord(i) >= 97 and ord(i) <= 122):
        #concatenate to empty string
        String2+=i
print('Alphabets in string are :' + String2)