【问题标题】:How to display {} as part of python f string [duplicate]如何将{}显示为python f字符串的一部分[重复]
【发布时间】:2021-09-16 13:05:27
【问题描述】:

有什么方法可以将 {} 显示为 f 字符串的一部分,因为它在 f 字符串中具有特殊含义。换句话说:

如果运行 print(f"hello world {}") ,我想要类似 hello world {} 的结果

我尝试的解决方案是:print(f"hello world \{\}")。但它不起作用。

非常感谢您的帮助

【问题讨论】:

  • br = '{}';print(f'hello world {br}')
  • print(f'Hello world {{}}')
  • 是的,这很好用

标签: python python-3.x curly-braces f-string


【解决方案1】:

这应该可以工作

print(f"hello world {{}}")

【讨论】:

    猜你喜欢
    • 2020-05-25
    • 1970-01-01
    • 2021-08-10
    • 1970-01-01
    • 2021-02-10
    • 1970-01-01
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多