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 | |
import os | |
import sys | |
import subprocess | |
def startFile(filepath): | |
if sys.platform.startswith('darwin'): | |
#MacOs |
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
function TFormPrincipal.Assinar(pArquivoXML, pTagAssinar: String): Boolean; | |
var | |
Fentrada:File; | |
NumRead,i, resultado:integer; | |
buf: char; | |
S: string; | |
Util: OleVariant; | |
XMLString, tagAssinatura, Atributo, XMLAssinado, msgResultado: Widestring; | |
SL: TStringList; | |
begin |
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 | |
from subprocess import Popen, PIPE | |
cmd = 'uname -a' | |
p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE) | |
out, err = p.communicate() | |
code = p.returncode |
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 | |
def teste(n, x=0): | |
if n == 0: | |
print n | |
print "--------------------------------------------" | |
print x | |
else: | |
print n |
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 csv | |
my_list = ["Matrix", "Blade Runner", "GodFather"] | |
new_csv = csv.writer(open("my_csv.csv", "wb")) | |
new_csv.writerow(["Nome do Filme"]) | |
for row in my_list: | |
new_csv.writerow([row]) |
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 | |
import requests | |
import BeautifulSoup | |
#Faz a requisição | |
req = requests.get('http://pcdsh01.on.br/HoraLegalBrasileira.asp') | |
#Obtem os dados no HTML | |
soup = BeautifulSoup.BeautifulSoup(req.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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from sys import argv | |
import unittest | |
class FrequenciaTest(unittest.TestCase): | |
def test_string_vazia(self): | |
self.assertEqual({}, frequencia('')) |
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 | |
# -*- coding: utf-8 -*- | |
from sys import argv | |
import unittest | |
class FatorialTest(unittest.TestCase): | |
def test_rNegativo(self): | |
self.assertRaises(ValueError, rFatorial(-1)) |
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 | |
# -*- coding: utf-8 -*- | |
""" | |
Provavelmente existe a 3ª exceção: | |
Quando o número for múltiplo de 3 e 5 escrever 'ping pong' em vez do número. | |
""" | |
n = 1 | |
while n < 101: | |
m3 = (n % 3 == 0) |
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 | |
# -*- coding: utf-8 -*- | |
""" Funções básicas """ | |
def nao(a): | |
a = int(a) | |
if a == 0: | |
return 1 | |
if a == 1: |
NewerOlder