标签: python
我想在一个句子中删除包含非字母字符的标记。
示例:
输入:"I like python@ pretty muc*h."
"I like python@ pretty muc*h."
输出:"I like pretty"
"I like pretty"
答案 0 :(得分:0)
您可以使用str.isalpha:
str.isalpha
s = "I like python@ pretty muc*h." print " ".join([i for i in s.split() if i.isalpha()])