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