简体   繁体   English

类型错误:字符串索引必须是整数? 我该如何解决

[英]TypeError: string indices must be integers ? how i can solve it

how i can return key and value for this dic?我如何为这个 dic 返回键和值?

store_group_details={'app_group3': ['calculater', 'google'],
 'Date': '2022-02-14',
 'Time': '03:00:00', 
'group name': 'test1'} 

✔ output ✔ 输出

app_group3:
 ['calculater', 'google']
Date:
 2022-02-14
Time: 
03:00:00
group name:
 test1

You can iterate the dict by using .items() method您可以使用.items()方法迭代字典

store_group_details = {'app_group3': ['calculater', 'google'],
                           'Date': '2022-02-14',
                           'Time': '03:00:00',
                           'group name': 'test1'}
for k,v in store_group_details.items():
    print(k, '\n', v)

You may read more here你可以在这里阅读更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM