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 urllib.request import Request, urlopen | |
import json | |
req = Request( | |
url='https://api.chucknorris.io/jokes/random', | |
headers={'User-Agent': 'Mozilla/5.0'} | |
) | |
resp = urlopen(req).read() | |
data = json.loads(resp.decode('utf-8')) |
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 random import randint | |
print ('Bem vindo!') | |
sorteado = randint(1, 100) | |
chute = 0 | |
while chute != sorteado: | |
chute = int(input ('Chute: ')) | |
if chute == sorteado: | |
print ('Você venceu!') | |
else: | |
if chute > sorteado: |
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 urllib.request | |
import json | |
from pprint import pprint | |
url = 'https://graph.facebook.com/fmasanori' | |
resp = urllib.request.urlopen(url).read() | |
data = json.loads(resp.decode('utf-8')) | |
pprint (data) | |
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 requests | |
jogos = requests.get('http://worldcup.sfg.io/matches').json() | |
for jogo in jogos: | |
if jogo['status'] in ('completed', 'in progress'): | |
print (jogo['home_team']['country'], jogo['home_team']['goals'], 'x', | |
jogo['away_team']['country'], jogo['away_team']['goals']) |
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
texto = open('alice.txt').read().lower() | |
from string import punctuation | |
for c in punctuation: | |
texto = texto.replace(c, ' ') | |
texto = texto.split() | |
dic = {} | |
for p in texto: | |
if p not in dic: | |
dic[p] = 1 | |
else: |
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
#Sorry, in April 30, 2015, with Facebook 2.0 API update only friends that use the app will be show | |
import urllib.request | |
import json | |
def save_image(friend): | |
size = '/picture?width=200&height=200' | |
url = 'https://graph.facebook.com/'+ friend['id'] + size | |
image = urllib.request.urlopen(url).read() | |
f = open(friend['name'] + '.jpg', 'wb') | |
f.write(image) |
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
Oficina MongoDB e Python - FISL | |
Resumo https://university.mongodb.com/courses/M220P/about | |
Install python 3.x (provavelmente vc já tem, 3.7 no mínimo) | |
https://www.python.org/downloads/ | |
para testar python -V | |
Install mongoDB última versão (mínimo 4.x) | |
https://www.mongodb.org/downloads | |
criar diretório \data\db com as permissões necessárias para testar bin\mongod (servidor) |
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 dec2bin(n): | |
b = '' | |
while n != 0: | |
b = b + str(n % 2) | |
n = int(n / 2) | |
return b[::-1] | |
def d2b(n): | |
if n == 0: | |
return '' |
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 tkinter import * | |
from sound_panel import * | |
import pygame.mixer | |
import os | |
app=Tk() | |
app.title('Head First Mix') | |
mixer = pygame.mixer | |
mixer.pre_init(buffer = 300) | |
mixer.init() |
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
#!/usr/bin/env python | |
""" | |
Converts PDF text content (though not images containing text) to plain text, html, xml or "tags". | |
""" | |
import sys | |
import logging | |
import six | |
import pdfminer.settings | |
pdfminer.settings.STRICT = False |
NewerOlder