Questions tagged as 'python'

1
answer

get the sum of an attribute django models

Good morning: I have a model Order and I need general a summary of all the orders that have been generated in the last 15 days, then I want to generate the total of all the orders and I do not know how to do it. for the moment I have this: ped...
asked by 18.01.2018 / 09:48
3
answers

How to do an accountant recursively?

I need to do a recursive function that counts from 1 to a number entered by the user. I have this: def contador(num): #caso base if num == 1: return num else: return contador(num) num=int(input("Hasta que número...
asked by 19.01.2018 / 22:28
1
answer

Change time to UTC

I have a doubt I think simple: I have a time read in a file and want to change it to UTC format. For example: #esto es lo que tengo importado: import datetime ,time from pytz import timezone def cambio_fecha_hora_utc(): fecha = 201806...
asked by 13.06.2018 / 17:41
2
answers

How to emulate the do-while cycle in python?

Some of you could tell me how to emulate the do-while cycle in python, looking for in different pages I found the following code while True: stuff() #que hace esa funcion o alguno puede ser tan amable de darme un ejemplo de uso if f...
asked by 19.02.2018 / 21:24
1
answer

add text to the beginning of my text file

I was trying to add text to a text file at the beginning but it always puts it at the end. My question is how could I make the text that I add, in python, add it to me at the beginning and not at the end? I will have a text file, eg: Mifichero...
asked by 09.03.2018 / 00:07
1
answer

view based on django functions

I am making progress in the development of django with an application, initially with the use of function-based views, my idea is also to handle views based on classes, and I am with an application that allows me to recover a record from a table...
asked by 13.12.2017 / 19:50
2
answers

Adding a home page with django

I have my application in django and I want to add a new page called homepage.html so in my project called web in the views.py I added: def homepage(request): return render_to_response('homepage.html', context_instance=RequestCo...
asked by 15.11.2017 / 18:52
1
answer

New in python: What does or does not affect "if __name__ == '__main__':" [duplicate]

How about, I'm working with a simple example of a python book, with sockets, and punctually after declaring 2 functions, in what would be the main the following is put: if __name__ == '__main__': main() My doubt is, in what affect the pro...
asked by 29.10.2017 / 06:08
2
answers

Run python file string

I want to run several similar programs one after the other in the terminal. archivo1.py archivo2.py archivo3.py I must not unite the 3 files and create 1 only with the functions of the three, what I am looking for is that I can create a new...
asked by 05.10.2017 / 23:02
2
answers

openpyxl import ranges and convert into dictionary

On an Excel sheet I have a table with two columns (Date and Value). The date has the format dd/mm/yy . With the script I show below I import the data contained in the A63:B80 range of said Excel sheet. #!/usr/bin/env python # -*-...
asked by 18.09.2017 / 20:25