小编cal*_*pto的帖子

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

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

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

python error-handling python-3.x f-string

1
推荐指数
1
解决办法
186
查看次数

标签 统计

error-handling ×1

f-string ×1

python ×1

python-3.x ×1