Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 Python 新手,这可能是一个非常简单的问题,但我无法弄清楚。我有一些需要转换的原始输入。输入是一段文本,例如,'ABCDEFGHIJKLMNO'但为了让我继续,我需要将其转换为字符串,例如'ABC DEF GHI JKL MNO'.
'ABCDEFGHIJKLMNO'
'ABC DEF GHI JKL MNO'
>>> s = 'ABCDEFGHIJKLMNO' >>> ' '.join([s[i:i+3] for i in xrange(0, len(s), 3)]) 'ABC DEF GHI JKL MNO'