001、
[root@pc1 test2]# ls test.py [root@pc1 test2]# cat test.py ## 测试程序 #!/usr/bin/env python3 # -*- coding: utf-8 -*- import re str1 = "abcdefghijklmn" print(str1) list1 = re.findall(".{3}", str1) ## 按照每3位生成列表 print("-".join(list1)) ## 列表转换为字符串 [root@pc1 test2]# python3 test.py abcdefghijklmn abc-def-ghi-jkl
。