你的
host_dict
installed_applications
值作为列表,因此可以将项附加到此列表,每个项都是dict,如下所示:
apps = get_installed_apps(host)
host_dict = {'installed_applications': []}
for app in apps:
new_app = {
'name': app[0],
'version': app[1],
'uninstall_string': app[2],
'install_date': app[3],
'install_location': app[4],
'publisher': app[5]
}
host_dict['installed_applications'].append(new_app)
host_dict['installed_applications']
将有一个列表,其中每个值都是
应用程序
host_dict = {
'installed_applications': [
{
'name': 'alsdfasdf',
'version': '1',
'installed_date': '11-11-11',
},
{
'name': 'alsdfasdf',
'version': '1',
'installed_date': '11-11-11',
},
{
'name': 'alsdfasdf',
'version': '1',
'installed_date': '11-11-11',
},
{
'name': 'alsdfasdf',
'version': '1',
'installed_date': '11-11-11',
}]
}