繁体   English   中英

如何在 Python 中没有引号和括号的情况下打印它?

[英]How do I print this without quotation marks and brackets in Python?

这是我的代码

keys = {"setup", "punchline"}

l = [{k:v for k, v in i.items() if k in keys} for i in response_dict]


print(json.dumps(l, indent=4, sort_keys=False))
    {
        "setup": "What's the best part about TCP jokes?",
        "punchline": "I get to keep telling them until you get them."
    },
    {
        "setup": "How many programmers does it take to change a lightbulb?",
        "punchline": "None that's a hardware problem"
    },
    {
        "setup": "What's the best thing about a Boolean?",
        "punchline": "Even if you're wrong, you're only off by a bit."


Deisred 输出设置:TCP 笑话最好的部分是什么? 妙语:我会一直告诉他们,直到你得到他们。

欢迎使用 StackOverflow!

以下是帮助您完成此任务的成分:

想想你将如何在l[0]输出一个笑话。 l[0]['setup']里面有什么, l[0]['punchline']什么?

暂无
暂无

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

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