This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup | |
html = 'lt;p><span style="font-weight: 400;">Você não teve o e-mail pessoal criado por falta de informações, para a criação você deve abrir um novo chamado com os seguintes dados:</span></p><p><strong>CPF -</strong></p><p><strong>NOME COMPLETO - </strong></p><p><strong>MATRÍCULA -</strong></p><p><strong>CARGO -</strong></p><p><strong>TELEFONE -</strong></p><p><strong>SETOR -</strong></p>' | |
soup = BeautifulSoup(html, 'html5lib') | |
print(soup.get_text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from html.parser import HTMLParser | |
class Parser(HTMLParser): | |
# method to append the start tag to the list start_tags. | |
def handle_starttag(self, tag, attrs): | |
global start_tags | |
start_tags.append(tag) | |
# method to append the end tag to the list end_tags. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def maiuscula(funcao): | |
def wrapper(texto): # função que modifica | |
return funcao(texto.upper()) # transforma pra maiúscula | |
return wrapper # retorna a função modificadora | |
@maiuscula | |
def imprimir_mensagem(nome): | |
print(f"Olá {nome}, \nSeja bem vindo!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
mydb = mysql.connector.connect( | |
host="127.0.1.1", # ip do banco | |
user="usuario", | |
passwd="senha", | |
database="banco_glpi" | |
) | |
mycursor = mydb.cursor() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
try: | |
if sys.argv[1] in sys.argv: # Caso exista argumento 1 | |
match sys.argv[1]: | |
case "oi": | |
print("\nOlá pessoa!") | |
case "tchau": | |
print("\nTchau, até logo!") | |
case _: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Exibindo comentários em ordem cronológica reversa. | |
Os mais recentes aparecem primeiro. | |
https://docs.python.org/3/howto/sorting.html | |
""" | |
comentarios = [ | |
['2023-1-29 11:03:00',"Agora entendi o problema"], | |
['2023-1-29 11:04:01',"Quase finalizando"], | |
['2022-12-29 8:32:49',"Recebi sua mensagem"], | |
['2022-12-30 4:14:58',"Ainda não entendi o problema"], |
NewerOlder