카테고리 없음

python - f-string & printf-style string formatting

꿈꾸는 사람_Anthony 2022. 3. 23. 21:20
반응형

Standard Format Specifiers

나중에 정리함..

다만, [0]은 그 자리에 0만 있거나 없어야한다. 0 padding(zero padding)이다. (minimum width만큼)

 

+ f-string이나 format을 이용하는.. 즉 printf-style string formatting이 아니면, 정수가 아닌 실수 등을 'd' specifiers에서 받을 수 없다.

```

print(f"{1.0:d}") # error

print("%d"%1.0) # good

```

 

Refs..

https://docs.python.org/3/library/string.html#formatstrings

https://docs.python.org/3/library/stdtypes.html#old-string-formatting

https://peps.python.org/pep-3101/?fbclid=IwAR1whZSHvpGSVwiP-Cp0yykalgvdDSS2sackY5up_xkomET-kCOcomL1ckY#standard-format-specifiers 

https://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting

f-string

https://docs.python.org/3/reference/lexical_analysis.html#f-strings

https://docs.python.org/3/library/functions.html#format

https://docs.python.org/3/library/string.html#formatspec

https://docs.python.org/3/library/string.html#formatexamples

 

 

반응형