我想知道如何在 python 中将字符串转换为多维列表,我需要的输出是
[['K','A','R','A','L','L','O','C'],
['G','N','T','E','B','M','A','I'],
['B','H','E','O','C','P','F','M'],
['R','U','N','E','O','F','U','M'],
['A','W','G','K','D','U','R','A'],
['V','D','R','E','C','A','Z','S'],
['E','M','J','A','L','O','T','S'],
['O','X','V','A','C','U','N','U']]
但我只知道如何转换成这种形式
[['KARALLOC'], ['GNTEBMAI'], ['BHEOCPFM'], ['RUNEOFUM'], ['AWGKDURA'], ['VDRECAZS'], ['EMJALOTS'], ['OXVACUNU']]
我的代码是这样的:
from textwrap import wrap
def words(letters):
gridLetters = wrap(letters,8)
separarParabras = [gridLetters[i*1:i*1+1] for i in range(8)]
return separarParabras
print(words('KARALLOCGNTEBMAIBHEOCPFMRUNEOFUMAWGKDURAVDRECAZSEMJALOTSOXVACUNU'))
宝慕林4294392
偶然的你
哈士奇WWW
HUWWW
相关分类