my_list = ['42344 xxxxxx xxxx 12','31232 zzzzzz xxxxx 15','3111 yyyyyy aaaaaa 34']
#the symbols that should be removed before you reach the one you need
what_should_be_removed = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ']
i = 0
for string in my_list: #checking each element in my_list
for char in string: #checking each character in the phrase
if char in what_should_be_removed:
i += 1
else:
print(string[i:]) #slicing the string
i = 0
break
您可以通过列表理解在一行中实现这一点:
一种方法是将
str.split
放在空白处,然后切掉第一个元素,然后join
重新组合在一起输出
相关问题 更多 >
编程相关推荐