f-string with float formatting in list-comprehension
问题 The [f'str'] for string formatting was recently introduced in python 3.6. link. I'm trying to compare the .format() and f'{expr} methods. f ' <text> { <expression> <optional !s, !r, or !a> <optional : format specifier> } <text> ... ' Below is a list comprehension that converts Fahrenheit to Celsius. Using the .format() method it prints the results as float to two decimal points and adds the string Celsius: Fahrenheit = [32, 60, 102] F_to_C = ['{:.2f} Celsius'.format((x - 32) * (5/9)) for x in