What can not be done with f-string that you can do when using .format?

1

Hello, I would like to know in what cases I need to use the format method instead of f-string because with f-string I can not do it. For example I think it is not possible with f-string to write a formatted number:

'fps: {:.1f}'.format(55.3578) => fps: 55.3
    
asked by anonymous 16.07.2018 / 04:06

1 answer

2

Actually, it does.

f"fps {55.3578:.1f}"

fstrings accepts any valid Python expression, and you can still put the ":" to specify the formatting, using all the possibilities that exist for format .

    
16.07.2018 / 15:52