import re number = "123456789" result = re.findall("\d{1,2}", number) print(result) # ['12', '34', '56', '78', '9']
import textwrap
s = ' '.join(textwrap.wrap(text='123456', width=2))
print(s)
import re number = "123456789" result = re.findall("\d{1,2}", number) print(result) # ['12', '34', '56', '78', '9']
import textwrap
s = ' '.join(textwrap.wrap(text='123456', width=2))
print(s)
转载于:https://www.cnblogs.com/xaiobong/p/9914860.html