【发布时间】:2023-01-19 15:50:11
【问题描述】:
我需要将第一个列表格式化为与第二个列表相同的格式。
print(incorrent_format_list)
['AsKh', '2sAc', '7hQs', ...]
print(correct_format_list)
[['As', 'Kh'], ['2s', 'Ac'], ['7h', 'Qs'], ...]
我试过了:
for h in incorrect_format_list:
split_lines = h.split(", ")
# but the print output is this:
['AsKh']
['2sKh']
['7hQs']
#rather than what i need:
[['As', 'Kh'], ['2s', 'Ac'], ['7h', 'Qs'], ...]
【问题讨论】: