28.03.22 15:13, StrikerOmega пише:
And I want to grab some kind of value from it.
There is a powerful tool designed for solving such problems. Is is called regular expressions.
sample.grab(start="fruit:", end="\n") >> 'apple'
re.search(r'fruit:(.*?)\n', sample)[1]
sample.grab(start="tree:[", end="]") >> 'Apple tree'
re.search(r'tree:\[(.*?)\]', sample)[1]
sample.grab(start="quantity:{", end="}", list_out=True) >> [5, 3]
list(re.findall(r'quantity:\{(.*?)\}', sample)) _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/X5EOH4P6KOWIJ3CSPWY76H6BHRDU42P5/ Code of Conduct: http://python.org/psf/codeofconduct/