所以我需要的是识别模式“X”或“spaceCAPITAL” 例子:
string="Hello World, This is KZ"
该计划将挑选出来:
example_list = [W,T,K]
答案 0 :(得分:2)
>>> import re
>>> strs = "Hello World, This is KZ"
>>> re.findall(r'\s([A-Z])', strs)
['W', 'T', 'K']
答案 1 :(得分:0)
试试这个:
import re
re.findall(' ([A-Z])', string)