From b72557a580035f17a513384e21e430aae28f66d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Wed, 26 Oct 2022 11:04:42 -0300 Subject: [PATCH] =?UTF-8?q?Formata=C3=A7=C3=A3o=20de=20strings=20com=20f-s?= =?UTF-8?q?trings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aula26.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 aula26.py diff --git a/aula26.py b/aula26.py new file mode 100644 index 0000000..5119603 --- /dev/null +++ b/aula26.py @@ -0,0 +1,24 @@ +""" +Formatação básica de strings +s - string +d - int +f - float +.f +x ou X - Hexadecimal +(Caractere)(><^)(quantidade) +> - Esquerda +< - Direita +^ - Centro += - Força o número a aparecer antes dos zeros +Sinal - + ou - +Ex.: 0>-100,.1f +Conversion flags - !r !s !a +""" +variavel = 'ABC' +print(f'{variavel}') +print(f'{variavel: >10}') +print(f'{variavel: <10}.') +print(f'{variavel: ^10}.') +print(f'{1000.4873648123746:0=+10,.1f}') +print(f'O hexadecimal de 1500 é {1500:08X}') +print(f'{variavel!r}')