Does anyone help me strip the characters with strings so that I '[....] For example: a = newyork_74 [mylocation] b = # till the frost characters until you reach the first bracket [c = [mylocation] < P>
Do not consider any nested structures, a method will be used,
& gt; & Gt; & Gt; Leaving import from Tertol & gt; & Gt; & Gt; B = ''. Joey (drops (lambda c: c! = '[', A])> gt; & Gt; & Gt; B '[mylocation]' use another,
& gt; & Gt; & Gt; Import re & gt; & Gt; & Gt; Pat = re.compile (r '\ [. * \]') & Gt; & Gt; & Gt; B = pat.search (a) .group (0)> gt; & Gt; & Gt; B '[mylaw cation]'
No comments:
Post a Comment