1 Star 0 Fork 46

michaelssj/qytang_Python

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
2016.02.25 正则表达式扫描字串 719 Bytes
一键复制 编辑 原始数据 按行查看 历史
现任明教教主-乾颐堂 提交于 2016-02-25 09:36 . new file
def re_scanner(fileName):
patt = '(BJRack0[1-3])_(v.*)_(.*)_([0-9][0-9][0-9][0-9])_([0-9]|[0-9][0-9])_([0-9]|[0-9][0-9])_([0-9]|[0-9][0-9])_(.*)\.(.*)'
scan_result = re.match(patt, fileName)
results = {}
results['rackno'] = scan_result.group(1)
results['verno'] = scan_result.group(2)
results['name'] = scan_result.group(3)
results['year'] = scan_result.group(4)
results['month'] = scan_result.group(5)
results['day'] = scan_result.group(6)
results['hour'] = scan_result.group(7)
results['result'] = scan_result.group(8)
results['filetype'] = scan_result.group(9)
return results
if __name__ == '__main__':
fileName = 'BJRack03_ve_秦柯_2016_2_24_13_.txt'
print(re_scanner(fileName))
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/michaelssj/qytang_Python.git
git@gitee.com:michaelssj/qytang_Python.git
michaelssj
qytang_Python
qytang_Python
master

搜索帮助