Questions tagged as 'python'

1
answer

How to convert this code from version 2 to 3.4 of Python?

I am having difficulty converting the code below to Python's 3.4 version, the purpose of this code is to encode and decode hexes in order to create shellcodes . import binascii, sys, time RED = '3[31m' WHITE = '3[37m' RESET = '3[0;0m' def...
asked by 03.04.2015 / 07:18
1
answer

How to build a queryset that only returns the cars with the last approved revision?

I want to create a queryset that returns only the cars that had the last approved revision. It is known that there may be n cars, and each car has a history of revisions, so there may be no revisions for each car. class Carro(models.Model):...
asked by 26.02.2015 / 03:44
2
answers

Difference between dates / times in Python

I need to calculate the difference between two dates in python, but always some error. >>> from datetime import datetime >>> data1 = datetime(2015, 8, 5, 8, 12, 23) >>> data2 = datetime(2015, 8, 9, 6, 13, 23) >>...
asked by 13.08.2015 / 21:10
1
answer

Are there any problems with using special characters in Python codes?

Thinking of making the codes leaner and more elegant would it be possible to use special characters in the codes? Would you get in trouble?     
asked by 06.12.2018 / 23:52
1
answer

What are environment variables?

I have seen many questions, articles and even some modules in the standard Python library where a term that is "environment variables" is introduced. Here in StackOverflow there are many issues that speak of them, but always on how to manipulate...
asked by 27.10.2018 / 23:39
1
answer

Slicing String and saving the slices in a PYTHON List

Hello, I'd like to understand a little more about strings in PYTHON . I'm developing a program, which consists of: Get a STRING Separate STRING every 3 characters And save each part in a LIST EX: nome = "guilherme"...
asked by 11.11.2018 / 06:26
2
answers

python string manipulation

I'm having a problem with python \ b (backspace), instead of deleting the previous character, it generates a "•" as shown below: Thefollowingisthelineofcodethatgeneratesthisreturn:#-*-coding:utf-8-*-importpyodbcimportplatformimportjson#-----...
asked by 04.07.2018 / 22:30
1
answer

Is it possible to inherit a class in python without writing all the attributes in the definition?

I have the following sample code: from Testes import POO class Fisica(POO.Cliente): def __init__(self,sexo,nome,idade): super().__init__(nome,idade) self.sexo = sexo Note that the attributes name and age are the attribut...
asked by 20.09.2018 / 03:15
2
answers

API StackOverFlow, "quota_max"

Hello, I'm using a collector to fetch data from all stackoverflow forum users through the API. But I am suffering from the "quota_max" that are only 300 searches per day. I've tried the Sleep function, put the sink to sleep for up to 300 seconds...
asked by 18.08.2014 / 23:57
3
answers

How to calculate the median of a large number of values?

I have a list with approximately 1.5 million values and I need to define the median of this set. The values are stored in a file, such as string , enclosed in single quotation marks (ex. '155' ). How can I calculate the median of this...
asked by 09.08.2018 / 20:18