Questions tagged as 'python'

1
answer

list dictionary elements and a list in a line

Hi, I'm doing a test with lists and dictionaries, I got to a point where I had something like that. datos = {'key1':'a','key2':'b','key3':'c'} dic = ["alfa","beta","gama"] My intention is to print a,alfa b,beta c,gama I tried it with a...
asked by 30.06.2017 / 08:20
3
answers

Use of def __unicode __ (self):

Use Django 1.9. I have two models related to each other, one contains an id and name among other attributes and the other contains its own id along with the id of the first model: class Televisor(models.Model): idTelevisor = models.AutoFie...
asked by 10.02.2016 / 02:44
2
answers

string to list in python

Hello How can I convert string '[1,2,3,4]' to list in python having the following p> valor_inicial = str([1,2,3]) Now I want that initial_value to convert it into a list. How can I do it?     
asked by 05.10.2018 / 23:56
1
answer

Python: compare two files and export it

Searching the web I have managed to show the differences between two text files in a new one, with the following code: with open('file1.txt', 'r') as file1: with open('file2.txt', 'r') as file2: difference = set(file1).difference(f...
asked by 13.05.2018 / 17:24
1
answer

Empty graphic in Jupyter

I am replicating this code to plot a line and a point but when I try to visualize the graphic it is empty. %matplotlib inline from matplotlib import pyplot from shapely.geometry import LineString, Point, LinearRing # Datos de entrada Line =...
asked by 20.03.2018 / 15:38
2
answers

Modify sql exit with python

When doing a query of a certain line of a database (MySQl) with python, the output it offers is of the type: Db_Host = '****' Db_Urs = '****' Db_Pass = '****' Db_Name = '****' def run_query(query=''): datos = [Db_Host, Db_Urs, Db...
asked by 18.06.2016 / 10:04
2
answers

Problem with Python, I get this error: 'NoneType' and 'NoneType'

Good morning, I have this code and it turns out that I get this error when I compile    Traceback (most recent call last): File "questionnaire__5.py", line   25, in       aa = (a) / (b) TypeError: unsupported operand type (s) for /: 'NoneType...
asked by 31.07.2017 / 13:24
1
answer

Transform an "exec ()" of python into str

I'm doing some experiments in python, I was wondering if it's possible to transform a exec() into a string, example: def prueba(): print("hola mundo") var = exec("prueba()") The idea is that the variable "var" has the value "hell...
asked by 29.09.2018 / 23:03
1
answer

How do I use serialized data in Python?

I have the following website: <html> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" /> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script src="...
asked by 28.08.2017 / 21:06
2
answers

List assignments

a = [0,0] b = a b[0] += 1 print(a) Output: [1, 0] Why does a change when I change b ?     
asked by 02.02.2017 / 13:03