Найти - Пользователи
Полная версия: SRE_Pattern repr
Начало » Python для новичков » SRE_Pattern repr
1
crchemist
маю змінну patt в приблизно такому коді:
>>> import re
>>> p = re.compile('my pattern')
>>> print p
<_sre.SRE_Pattern object at 0x02274380>
>>>
можна якось з patt витягнути стрічку “my pattern” ?
crchemist
p.pattern. дивно що dir не показав цього атрибуту:
>>> sys.version
'2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)]'
>>> dir(p)
['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', 'subn']
>>> p.pattern
'my pattern'
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB