May 10, 2021 Python2
In this section we simply talk about two ways to parse text:
1. Shrapning, by shrapning, recording the offset, and then extracting the desired string
Example:
>>> line='aaa bbb ccc'
>>> col1=line[0:3]
>>> col3=line[8:]
>>> col1
'aaa'
>>> col3
'ccc'
>>>
2. split()
>>> line='aaa bbb ccc'
>>> a=line.split (' ')
>>> a
['aaa', 'bbb', 'ccc']
>>> a[0]
'aaa'
>>> a[1]
'bbb'
>>> a[2]
'ccc'
>>>
>>> line='aaa,bbb,ccc'
>>> a=line.split (',')
>>> a
['aaa', 'bbb', 'ccc']
>>>
Using the split method, different characters are extracted based on the signature
Although the above two methods have limited potential for normal text resolution, they are useful for passing values when we normally program
For example, the json string is one of the more typical examples, using the three symbols, which are used to separate the various objects