Python 使用f字符串打印字典的所有键

Python 使用f字符串打印字典的所有键,python,dictionary,f-string,Python,Dictionary,F String,我尝试使用f字符串打印字典的所有键 我目前的解决办法是 data = {'key1': 1, 'key2': 2, 'key3': 3} print{f'All keys are {", ".join(data.keys())}.' 它将打印预期输出: "All keys are key1, key2, key3." 有没有更好的解决方案不需要使用join()。

我尝试使用f字符串打印字典的所有键

我目前的解决办法是

data = {'key1': 1, 'key2': 2, 'key3': 3}
print{f'All keys are {", ".join(data.keys())}.'
它将打印预期输出:

"All keys are key1, key2, key3."

有没有更好的解决方案不需要使用join()。