chinapnr/fishbase

common, split_str_by_length 按照特定长度分割长文本字符串

mindjun opened this issue · 0 comments

背景

  • 需要操作长字符串特定长度的子串

步骤

  • 参数 text 为需要分割的长文本字符串
  • 参数 length 子字符串的长度

举例

text = '1231'*4 + '12'
str_list = split_str_by_length(text, 4)
str_list
>>> ['1231', '1231', '1231', '1231', '12']