how to grep
Steve D'Aprano
steve+python at pearwood.info
Fri Aug 4 08:37:47 EDT 2017
On Fri, 4 Aug 2017 10:33 pm, Iranna Mathapati wrote:
> Hi Team,
>
> How to grep values from below out put string.
>
> pattern should include "Fabric Module".
>
> grepping Fabric module values only
>
> str = '''
> 22 0 Fabric Module J8N-C9508-FM ok
> 24 0 Fabric Module J8N-C9508-FM ok
> 26 0 Fabric Module J8N-C9508-FM ok
> 22 0 16-slot Fabric Module J8N-C9516-FM-E ok
> 24 0 16-slot Fabric Module J8N-C9516-FM-E ok'''
>
> output = [22,24,26,22,24]
output = int(line[:2]) for line in string.split('\n') if line]
Does that help?
If not, you will need to ask a better question, because I cannot understand the
question you are asking now.
--
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list