Questions tagged as 'python'

1
answer

How to use Form in ListView Django?

I'm trying to create an action for a ListView, the action would be to delete or change a parameter in the table, for example, disable user, using checkbox. If I select all and click this button it will delete all selected. views.py class Ac...
asked by 19.02.2017 / 14:46
0
answers

How to extract information from an HTTP header with Python?

We know that in the HTTP protocol, the end of the header is indicated by " \r\n\r\n ". Example: Forsomereason,theclientmaynotsendthe" \r\n\r\n " to the server (this could be an attack, for example): Suppose I have a netw...
asked by 01.09.2017 / 17:15
1
answer

How to construct a query with Web2py quantifying the difference between days

I'm using Web2py (Python), doing the query using DAL I wonder if it's possible to get the difference in days, something close to that Example #!/usr/bin/env python # -*- coding: utf-8 -*- resultado = db( (db.base_suporte.dt_...
asked by 21.02.2015 / 03:07
3
answers

Redeem only 10 first Python object records

I'm curled up in a part of the code I'm doing. I need to retrieve only the first 10 records of an object that I call in a for loop: listaTabela = [] for aluno in alunos: listaLinha = "" listaLinha += str(aluno.g...
asked by 18.07.2018 / 16:39
5
answers

Regex to capture dimensions of a product with unit of measure

I have a function in python to capture the dimensions of a product in LxCxA format but I can not make it work for cases where the unit of measure appears between the values, the regex is this here: def findDimensions(text): p = re.compile(...
asked by 29.06.2018 / 22:04
4
answers

How to generate random numbers for Draw? [closed]

I need to generate numbers for a promotion, these numbers should range from 0 to 99999. How can I distribute these numbers randomly and equitably, without repeating numbers already distributed?     
asked by 24.10.2016 / 23:44
2
answers

Is there any way to download a Youtube video using urllib?

Is there any way to download a video on youtube using urllib in Python? I tested, but it does not work (just an example): import urllib.request youtube = "" pagina = urllib.request.urlopen(youtube) urllib.request.urlretrieve("",...
asked by 02.01.2017 / 16:45
1
answer

Help tables python27

Good morning, I'm new to Python / Tkinter and I have some projects in mind, but they all have tables using them, could anyone tell me if some library I could use to create these tables or some way to create them? I tried to use tkintertable but...
asked by 01.07.2014 / 14:12
2
answers

Why is the output coming out like this?

I'm trying to make a program in which I use a list and that program returns 2 lists one with the other pairs with the odd ones. lista = [0,1,2,3,4,5,6,7,8,9,10] def par(numero): if numero % 2 == 0: return numero def impar(numero):...
asked by 11.12.2016 / 23:12
2
answers

How to do bulk assignment of variables in Python?

In PHP, to do a variable assignment "in bulk" (declare it on the same line), we can do it using the list function. Example: list($a, $b, $c) = array(1, 2, 3); How to make this type of bulk assignment in Python?     
asked by 14.08.2015 / 18:02