← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 eric.smith
收信人 barry, eric.smith, larry, levkivskyi, serhiy.storchaka
日期 2019-05-07.08:17:50
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1557217070.22.0.961332864006.issue36817@roundup.psfhosted.org>
In-reply-to
内容
> In you example the format spec is applied to both the value and the literal representation of the expression. Is it an error? I do not think this is an expected behavior.

No, you're misreading it. I admit that my example wasn't great. Try this one:

>>> for n in nums:
...   print(f'*{n=:+<30}*')
... 
*n=0.3333333333333333++++++++++++*
*n=1.0+++++++++++++++++++++++++++*
*n=10.0++++++++++++++++++++++++++*
*n=3.141592653589793+++++++++++++*

> If you want to apply it to both the literal expression and its value you can use the nested f-string: f"*{f'{n=}':30}*".

Correct. There's a similar discussion in issue36774.
历史
日期 用户 动作 参数
2019-05-07 08:17:50eric.smith修改recipients: + eric.smith, barry, larry, serhiy.storchaka, levkivskyi
2019-05-07 08:17:50eric.smith修改messageid: <1557217070.22.0.961332864006.issue36817@roundup.psfhosted.org>
2019-05-07 08:17:50eric.smith链接issue36817 messages
2019-05-07 08:17:50eric.smith创建