[英]strip dictionary of {}, “” and : python3
I want to know how to strip a dictionary as so我想知道如何剥离字典
>>> dict = {"hello", "world"}
>>> print(dict)
{"hello" : "world", "hi" : "StackOverflow"}
how do I make it output我该怎么做 output
hello world
hi StackOverflow
Try this:尝试这个:
my_dict = {"hello" : "world", "hi" : "StackOverflow"}
for i, j in my_dict.items():
print(i, j)
Output: Output:
hello world
hi StackOverflow
Iterate through the dict.items()
and print according to the format you want.遍历
dict.items()
并根据您想要的格式打印。
for k,v in dict.items():
print("{} {}".format(k,v))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.