stay Python in , It is often used f-string Used to format the output string , For various development needs , But do you know any other powerful operations ? I'll give you a list today .

<> Direct output variable name , Make your code simpler , Grammar is based on Python3.10
string = 'Hello Medusa' print(f'{string = }') string = 'Hello Medusa'
<> Directly calculate the results and change the output , Grammar is based on Python3.10
number = 1024 print(f'{number % 1 =}') number % 1 =0
<> Format and output the event object directly , Grammar is based on Python3.10
datetime = datetime.datetime.now() print(f'{datetime:%Y-%m-%d %H:%M:%S}') 2021-
12-31 16:03:20
<> Binary conversion output , Grammar is based on Python3.10
number_10 = 1024 print(f'{number_10:b}') # 2 Base system print(f'{number_10:o}') # 8 Base system
print(f'{number_10:x}') # 16 Hexadecimal lowercase print(f'{number_10:X}') # 16 Hexadecimal uppercase print(f'{
number_10:c}') # ASCII code 10000000000 2000 400 400 Ѐ
<> Format floating point number , Grammar is based on Python3.10
number_float = 1024.123 print(f'{number_float = :.2f}') # Keep two decimal places
number_float_format= '.3f' print(f'{number_float:{number_float_format}}') #
Parameter nesting , Keep three decimal places number_float = 1024.12 1024.123
<> String to its , Grammar is based on Python3.10
text = 'Medusa' print(f'{text:>10}') # Right align print(f'{text:<10}') # Align left print(f'{
text:^10}') # Center alignment print(f'{text:*^10}') # Center alignment , use * Fill in the blanks n = 10 print(f'{text:~^{n
}}') # Parameter nesting , Center alignment , use ~ Fill in the blanks Medusa Medusa Medusa **Medusa** ~~Medusa~~
<>!s and !r, Grammar is based on Python3.10
text = 'Medusa' print(f'{text!s}') # str(text) print(f'{text!r}') # repr(text)
Medusa'Medusa'
<> Custom format , Grammar is based on Python3.10
class MedusaFormatString: def __format__(self, format_spec): return format_spec
print(f'{MedusaFormatString():&1&2}') &1&2

Technology
©2019-2020 Toolsou All rights reserved,
Redis Underlying data structure A person who dissuades others from learning computer , Are not good people win10 System computer C Where's the disc ,c disc users where? (win10c Disk not found users) Freshman c Language student management system ( lower ) hospital WIFI Which family is strong ? utilize Python Script unlimited spoof girlfriend computer C language program design —— Student management system Byte runout - Test development practice - One side cool meridian python Run code at specified time 5 Best style Linux Server system recommendation Anti anxiety life after naked resignation , I believe everything will have the best arrangement