python - Removing all alphabets and commas from a string -
I have a large list that contains many elements that look like this:
I want to strip all the letters and I tried to use it: But it results in a list like this - Since a lot The big file is working inside the loop, so a line of code will really be helpful. Thanks You can () : Support (again. Fondal): 'A.21,48; B6 4, 91; C 9, 5, 125; D.139,166; E. 175,200 '
; . Include the letters and the list that lists the
['21', '48', '64', '91', '95', '125', '139', '166', '175 ',' 200 ']
import re list.append (re.sub ("\ D" / Code>
['21 48 64] 95 125 139 166 175 200']
re.findall () :
& gt; & gt; import re & gt; & gt; Gt; Strs ('21', '48', '64', ' , Re.sub using '91', '95', '125', '139', '166', '175', '200]]
gt;> ('21', '48', '64', '91', '95', '125', '13 9 ',' 166 ',' 175 ',' 200 ']
Find the help module again: Findall (patterns, strings, flags = 0) return a list of all non-overlapping matches in the string. If one or more groups are present in the pattern, return a list of groups; This will be a list of tuples if more than one group of patterns is included in the blank match result
Comments
Post a Comment