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
raw = {u'pf': {u'dados': {u'protocolo': u'fd6be408-a519-41e6-8beb-55712e2b79a6', u'ccf': u'NAO', u'data_nasc': u'1985-06-01', u'situacao_receita_federal': {u'situacao': u'REGULAR', u'dataconsulta': u''}, u'nome': u'MARCELO RODRIGO DOS SANTOS ANDRIOLLI', u'enderecos': {u'endereco': [{u'tipo_logradouro': u'AV', u'complemento': u'AP 302', u'bairro': u'KOBRASOL', u'cidade': u'SAO JOSE', u'logradouro': u'LEDIO JOAO MARTINS', u'numero': 584, u'score': 8, u'cep': 88101100, u'uf': u'SC'}, {u'tipo_logradouro': u'SRV', u'bairro': u'CAMPINAS', u'cidade': u'SAO JOSE', u'logradouro': u'ELVIRA SCHMIDT GOEDERT', u'numero': 8, u'score': 8, u'cep': 88101335, u'uf': u'SC'}]}, u'signo': u'G\xcaMEOS', u'cpf': 4353350900, u'faixa_renda_estimada': u'D', u'idade': 32, u'probabilidade_obito': 0, u'telefones_moveis': { | |
u'telefone': [4832411640, u'', u'', 48984833639, 48996219722, u'']}, u'mae': {u'nome': u'JANETE FRANCISCA DOS SANTOS'}, u'ocupacoes': {u'ocupacao': {u'telefones': {u'telefone': [8134650705, 4821080953, 4821080954, |
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/python -tt | |
# Copyright 2010 Google Inc. | |
# Licensed under the Apache License, Version 2.0 | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Google's Python Class | |
# http://code.google.com/edu/languages/google-python-class/ | |
# Basic string exercises | |
# Fill in the code for the functions below. main() is already set up |
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 match_ends(words): | |
i = 0 | |
for word in words: | |
if len(word) >= 2 and word[0] == word[-1]: | |
i += 1 | |
return i |
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
# The number 6 is a truly great number. Given two int values, a and b, | |
# return True if either one is 6. Or if their sum or difference is 6. | |
# Note: the function abs(num) computes the absolute value of a number. | |
# love6(6, 4) → True | |
# love6(4, 5) → False | |
# love6(1, 5) → True | |
# love6(7,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
>>> fruit = 'apple' | |
>>> fruit is 'apple' | |
True | |
>>> fruit == 'apple' | |
True | |
>> id(fruit), id('apple') | |
(140031285906720, 140031285906720) | |
>>> id(fruit), id('orange') |
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
2018-06-14 21:04:37 [scrapy.utils.log] INFO: Scrapy 1.5.0 started (bot: celesc) | |
2018-06-14 21:04:37 [scrapy.utils.log] INFO: Versions: lxml 4.2.1.0, libxml2 2.9.8, cssselect 1.0.3, parsel 1.4.0, w3lib 1.19.0, Twisted 18.4.0, Python 2.7.12 (default, Jun 13 2018, 21:52:00) - [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)], pyOpenSSL 18.0.0 (OpenSSL 1.1.0h 27 Mar 2018), cryptography 2.2.2, Platform Darwin-17.5.0-x86_64-i386-64bit | |
2018-06-14 21:04:37 [py.warnings] WARNING: /Users/marcelorsa/.pyenv/versions/pague_verde_bots/lib/python2.7/site-packages/scrapy/utils/deprecate.py:156: ScrapyDeprecationWarning: `scrapy.telnet.TelnetConsole` class is deprecated, use `scrapy.extensions.telnet.TelnetConsole` instead | |
ScrapyDeprecationWarning) | |
2018-06-14 21:04:37 [scrapy.middleware] INFO: Enabled extensions: | |
['scrapy.extensions.corestats.CoreStats', | |
'scrapy.extensions.feedexport.FeedExporter', | |
'scrapy.extensions.memusage.MemoryUsage', | |
'scrapy.extensions.logstats.LogStats'] |
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
class PersonTestCase(TestCase): | |
def test_should_return_attributes(self): | |
fields = ('first_name', 'last_name', 'age') | |
for field in fields: | |
with self.subTest(): | |
self.assertTrue(hasattr(Person, field)) |
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 openpyxl import load_workbook | |
wb = load_workbook(filename='ic5.xlsx', read_only=True) | |
ws = wb.get_sheet_by_name('Sheet1') | |
def iter_rows(ws): | |
for row in ws.iter_rows(): | |
yield[cell.value for cell in 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
from string import Template | |
class DefaultTemplateTag(Template): | |
delimiter = '{{' | |
pattern = ''' | |
\{\{(?: | |
(?P<escaped>\{\{)| | |
(?P<named>[_a-z][_a-z0-9]*)\}\}| | |
(?P<braced>[_a-z][_a-z0-9]*)\}\}| |
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
class ModelSchemaMixin: | |
model = None | |
def create(self, validated_data): | |
if not model: | |
raise serializers.ValidationError('There is no model defined.') | |
return self.model.objects.create(**validated_data) |
OlderNewer