# 正则注释写法
import re
url_t = "https://www.baidu.com/p/123/pid?=123456"
p_main = r'''
p/(?P<zt_name>\d+)/ #主贴id
pid?=(?P<reply_name>\d+) #回帖id
'''
tbsectcre = re.compile(p_main,re.VERBOSE)
tb_text = tbsectcre.search(url_t)
print(tb_text.group('zt_name'))