代码
import re
p = re.compile(r'(\d+)-(\d+)-(\d+)')
print(p.match('2018-05-10').group(2))
print(p.match('2018-05-10').groups())
year, month, day = p.match('2018-05-10').groups()
print(year)运行

赞赏作者


如果觉得我的文章对你有用,请随意赞赏




























import re
p = re.compile(r'(\d+)-(\d+)-(\d+)')
print(p.match('2018-05-10').group(2))
print(p.match('2018-05-10').groups())
year, month, day = p.match('2018-05-10').groups()
print(year)


如果觉得我的文章对你有用,请随意赞赏
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。