开发者社区 问答 正文

如何处理f字符串中的错误?

我正在尝试处理f字符串中的错误,但是我的尝试似乎没有用。有没有办法做到这一点?

string = f"For example I thought this syntax would work but it doesn't {try: 5/0 except Exception: str(infinity)}"

问题来源:stackoverflow

展开
收起
is大龙 2020-03-23 19:55:34 408 分享 版权
1 条回答
写回答
取消 提交回答
  • 你不能 将异常处理移出f字符串。

    回答来源:stackoverflow

    2020-03-23 19:55:40
    赞同 展开评论
问答地址: