如何从此结果中删除引号,逗号和括号:
encrypt = input("enter your string: ")
encrypt = encrypt.replace(" ","")
encrypt_list = [encrypt[i:i+5] for i in range(0, len(encrypt), 5)]
print (encrypt)
print (encrypt_list)
如果输入为:5 blocks of text test
输出为:['5bloc', 'ksoft', 'extte', 'st']
我需要它:5bloc ksoft extte st
答案 0 :(得分:0)
您可以使用str.join
,如下所示:
>>> s = ' '.join(['5bloc', 'ksoft', 'extte', 'st'])
>>> print(s)
5bloc ksoft extte st