要删除行首的数字,可以使用正则表达式来匹配并替换行首的数字为空字符串。以下是一个示例代码: ```python import re def remove_number_from_start_of_line(text): pattern = r'^\d+\s' # 匹配行首的数字和空格 return re.sub(pattern, '', text, flags=re.MULTILINE) # 示例用法 text = '''1. First line 2. Second line 3. Third line''' result = remove_number_from_start_of_line(text) print(result) ``` 输出结果为: ``` First line Second line Third line ``` 这样就删除了行首的数字。