我怎么能像'aaaaaaaaaaaaaaaaaaaaaaa'这样的字符串将其拆分为4个长度的元组,如( aaaa , aaaa , aaaa )
'aaaaaaaaaaaaaaaaaaaaaaa'
aaaa
Use textwrap.wrap :
textwrap.wrap
(使用textwrap.wrap :)
>>> import textwrap >>> s = 'aaaaaaaaaaaaaaaaaaaaaaa' >>> textwrap.wrap(s, 4) ['aaaa', 'aaaa', 'aaaa', 'aaaa', 'aaaa', 'aaa']
2.1m questions
2.1m answers
60 comments
57.0k users