摘要: 使用argparse添加命令行参数,代码如下: import argparse def main(number): print('#' * number) if __name__ == '__main__': parser = argparse.ArgumentParser() #parser.ad 阅读全文
posted @ 2022-04-09 22:16 轻舞飞洋 阅读(32) 评论(0) 推荐(0) 编辑
摘要: 示例如下: >>> import re >>> match = re.search(r'the phone number is ([\d-]+)', '37: the phone number is 1234-567-890') #\d: 标记任何数字(0-9)。 >>> match.group() 阅读全文
posted @ 2022-04-09 21:34 轻舞飞洋 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 一、示例如下: >>> import re #导入正则表达式模块 >>> re.search(r'LOG', 'SOME LOGS') <re.Match object; span=(5, 8), match='LOG'> #在字符串中查找'LOG' >>> re.search(r'^LOG', ' 阅读全文
posted @ 2022-04-09 11:41 轻舞飞洋 阅读(35) 评论(0) 推荐(0) 编辑