Python 3:用列表的一部分和标准部分创建一个变量,然后将该变量分配给新创建的列表

Python 3: Making a variable with a part of a list and a standard part and then assing that variable to a newly created list

我需要将一些字符串转换成一个列表,以及一个由其他列表组成的列表。 代码第一部分:

ww_onconverted = input("enter raw data:")
ww_spaces_to_tabs = ww_onconverted.replace(" ", "\t")
ww_spaces_to_tabs = ww_spaces_to_tabs.replace("-", " ")
ww_splitted = ww_spaces_to_tabs.split("\t")
print(ww_splitted)

所以当我输入时: abrir abriendo abrito abro,es,e,imos,en abrí,iste,ió,imos,ieron abría,s,-,mos,n abriré,ás,á,emos,án abre,abra

他列了一个这样的清单: ['abrir', 'abriendo', 'abierto', 'abro,es,e,imos,en', 'abrí,iste,ió,imos,ieron', 'abría,s, ,mos,n', 'abriré,ás,á,emos,án', 'abre,abra']

这是正确的方向,但我想列一个清单:

ww_splitted[0]_gerundio = [ww_splitted[1]]

所以当我使用我刚刚输入的信息时,代码需要这样: abrir_gerundio = abriendo

这多次然后我想制作一个名为 ww_splitted[0] = [ww_splitted[0]_gerundio]

我尝试使用函数 globals()、locals() 和 exec(),但对我来说没有用,因为我不太了解它们,我在互联网上搜索了它们但没有没有比基本示例更进一步的了,可能是因为我的英语不好。 谁能帮帮我?

-Blenrine

你想要的输出看起来不像一个列表,而是一个字典,它也更适合你正在做的事情。

dict = {ww_splitted[0]+"_gerundio" : ww_splitted[1]}