Questions tagged as 'python-2.7'

3
answers

Avoiding code duplication without the use of switch / case in the Python language

Friends, I have the following code in Python: data_hoje = time.strftime("%d %b %Y", time.gmtime() ) #data de hoje data_desejada = time.strftime("%d %b %Y", time.gmtime(time.time() + (3600 * 24 * 2))) # daqui a 2 dias I know that in Pyth...
asked by 01.03.2017 / 04:26
1
answer

AWS S3 Disabling support for SSLv3

I received an email from AWS that says basically that S3 will no longer support SSLv3. So they listed the list of buckets that are receiving requests in SSLv3 and one of my buckets is production. The full email can be viewed here: link M...
asked by 24.04.2015 / 21:38
2
answers

How do I read python row by line?

Let's suppose I have a txt file with some data: [File.txt] Oie Olá Tudo bem? I want something (in python) that reads line by line and print.     
asked by 26.09.2017 / 18:05
1
answer

What is the difference between Python versions 3.4, 3.5, 3.6, 3.7? [closed]

I thought Python only upgraded versions 2.7 to maintain compatibility but did not abandon previous versions of 3.x. But he insists on updating versions 3.4, 3.5, 3.6, 3.7 constantly. What do these different 3.x.x versions have to do differently?...
asked by 03.08.2018 / 21:35
3
answers

Regex for hexadecimal colors

I have a little doubt: I have a regex that captures in 3 groups (2 values per group) of a certain color, but this when I have 6 values (excluding #), I would like to know how to implement to catch < strong> 1 group when the color is for example...
asked by 27.03.2014 / 18:04
2
answers

Process NFe XML in Python

I have the following code that aims to fetch a particular node from an Electronic Invoice XML, but without success. I tested it with other XMLs and it worked. import xml.etree.ElementTree as ET tree = ET.parse("nfe.xml") doc = tree.getroot()...
asked by 01.06.2016 / 10:41
2
answers

Imports in file __init__.py

I am studying the documentation of Django and I noticed that in some __init__.py files there are imports, I know that the __init__.py file defines a module but I do not understand why it imports.     
asked by 09.08.2018 / 20:26
1
answer

How to improve a bar graph whose values are very close in Python?

I'm drawing the bar graph using the following Python code: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] with open("Tem...
asked by 14.09.2017 / 15:52
1
answer

Error in exception handling (try) in python

I'm doing a program that does numerical calculations, but I constantly see operations where there is division by 0 (zero) . I ended up finding a solution using if , but I still wanted to know why try can not handle this except...
asked by 09.12.2016 / 03:40
1
answer

How to read PDF

I'm creating a script to get a pdf and rewrite it in text. from StringIO import StringIO from slate import PDF from subprocess import Popen, PIPE, call import uuid #pego pdf existente url = "/tmp/arquivo.pdf" with open(url, "r") as arq:...
asked by 27.10.2016 / 22:59