Questions tagged as 'python-2.7'

3
answers

Add the value of a list of dictionaries with the same key

I have a list of dictionaries lst = [ {'x': 1, 'y': 2}, {'x': 1, 'y': 3 }, {'x': 2, 'y': 2 } ] Dictionaries always have the same keys and it is the values that change at all times. Then I would like to add the value of the keys "and" whe...
asked by 07.02.2018 / 10:58
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 / 15:41
2
answers

Dictionary encoded Python

I need to convert A to B. I work with Python 2.7 A: payload = {"trafficChannel":{"name":"tuviaasa","status":0,"billedEvent":"ai","env":"desktop","dealType":"fixed_price","optimizeAllAdSources":"false","optimizeFor":"ecpm","publisher":"5a031...
asked by 08.11.2017 / 20:21
1
answer

Iterate a list in Django

I have a model called Precompra and from there I am interested in the price to calculate the total for now. What is the problem with this code that is not showing me the result in the template. This code was programmed in view.py...
asked by 13.04.2017 / 15:48
1
answer

How they connect to my application via internet without being in the network lan [closed]

Hi I'm doing an application in python is with sockets, how do I do it so that another person who is not on the lan network (this on the internet) connects to my application in the specified port ??? I searched and found that ssh, nat is used and...
asked by 19.12.2016 / 20:47
1
answer

Update parameters b, and with loop

I have the following code, I need b, and they are updated try a for in the end of the code to update the values of the beginning but it did not give a good result. Code import scipy.optimize from scipy import optimize import numpy as np fro...
asked by 25.03.2017 / 05:11
1
answer

HOW DO I SOLVE IT? I get an error in line 110, in module Action_List (4) NameError: name 'Activity_List' is not defined?

# importando modulos necesarios import matplotlib.pyplot as plt import numpy as np import seaborn as sns import random as rm #Estados(Nodos)-->4 EVENTOS Estados=["Dormir","Entrenar","Correr","Jugar"] Lista_Actividad=[] #Posibles secuencia...
asked by 14.11.2018 / 00:12
1
answer

AttributeError (The 'NoneType' object has no 'name' attribute)

Here I have 2 tables the first one is for products and the 2nd one is for price, in the price table I call the product name but I get an error, please help models.py class Producto(models.Model): """Productos a la venta""" nombre...
asked by 20.11.2018 / 22:48
2
answers

I apply setText to a Qlabel of PyQt4 in Python and it does not modify the text in the tag but it is superimposed on the change

When I run the code a MainWindow appears in which there are two radioButtons, if I press either of the two, a container widget will be added and displayed in the main window, in it there will be several objects of which I care about the present...
asked by 03.07.2016 / 15:36
1
answer

AttributeError: 'Mul' object has no attribute 'eval'

I have a problem with this code, which calculates the eigenstates for the quantum harmonic oscillator and evaluates it in a given time. In turn, I try to plot all the state subplots for each value of n. But this error appears: for i in xx: reP...
asked by 30.09.2018 / 21:44