python模式标识符?正则表达式?

时间:2013-10-20 10:34:11

标签: python regex list

所以我需要的是识别模式“X”或“spaceCAPITAL” 例子:

string="Hello World, This is KZ"

该计划将挑选出来:

example_list = [W,T,K]

2 个答案:

答案 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)