This question shows research effort; it is useful and clear
0
This question does not show any research effort; it is unclear or not useful
Bookmark this question.
Show activity on this post.
这是我的代码:
import re
p = re.compile('(?P<name>[^|]*)|(?P<desc>[^|]*)')
m = p.match('jack|a good boy')
name = m.group('name')
desc = m.group('desc')
print name # jack
print desc # None
import re
p = re.compile('(?P<name>[^|]*)\|(?P<desc>[^|]*)')
m = p.match('jack|a good boy')
name = m.group('name')
desc = m.group('desc')
print name # jack
print desc # a good boy