Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/293.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python模式标识符?正则表达式?_Python_Regex_List - Fatal编程技术网

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

python模式标识符?正则表达式?,python,regex,list,Python,Regex,List,所以我需要的是确定模式“X”或“spaceCAPITAL” 示例: string="Hello World, This is KZ" 该计划将挑选: example_list = [W,T,K] 试试这个: import re re.findall(' ([A-Z])', string) 尽量避免命名字符串string。这是runcode()回溯中的一个{IDLE内部错误(上次调用):文件“C:\Python33\lib\idlelib\rpc.py”,第236行,在异步队列if thre

所以我需要的是确定模式“X”或“spaceCAPITAL” 示例:

string="Hello World, This is KZ"
该计划将挑选:

example_list = [W,T,K]
试试这个:

import re
re.findall(' ([A-Z])', string)

尽量避免命名字符串
string
。这是runcode()回溯中的一个{IDLE内部错误(上次调用):文件“C:\Python33\lib\idlelib\rpc.py”,第236行,在异步队列if threading.current_thread()!=self.sockthread:AttributeError:'MyRPCClient'对象没有属性'sockthread'}是我犯的错误吗encountering@user2899835这与我发布的代码无关。我知道,它不喜欢我重新导入。@user2899835 Google this:AttributeError:“MyRPCClient”对象没有属性“socksThread”,你会知道出了什么问题。
>>> import re
>>> strs = "Hello World, This is KZ"
>>> re.findall(r'\s([A-Z])', strs)
['W', 'T', 'K']