Questions tagged as 'python-3.x'

1
answer

Join repeated items in a list

I try to get that from the result of a function that is returning me lists of words like the following: [('algo', 1), ('de', 1), ('una', 1), ('de', 1), ('una', 1), ('y', 1), ('otra', 1), ('cabeza', 1), ('', 1)] that another function I go pi...
asked by 29.03.2018 / 11:31
1
answer

Optional routes in Flask

Is there any way to make optional routes? For example: @app.route(r'/contacts/<key>/<name>?', methods=['GET']) def contact_deatils(key, name = None): print(key, name) return 'mensaje de prueba' if you place parameters...
asked by 26.03.2018 / 23:26
1
answer

how to generate a csv of users in Django?

I have a problem trying to generate a CSV file with all registered users to export it. def descargar_usuarios(request): perfiles = Perfil.objects.all() response = HttpResponse(content_type='application/csv') with open('usuarios.csv','wb') as f...
asked by 05.03.2018 / 11:53
1
answer

Display information of a binary search tree python

In a class, I have a method where I call my binary tree module (do not pay attention to the name of the treeAVL) and I save the information that I take from the database: def ingresarArbol(self): arbol=ArbolAVL.ArbolBinarioBusqueda...
asked by 06.03.2018 / 04:33
1
answer

Systems of nonlinear equations in python

I have the following concern with a nonlinear equation system in python : from scipy.optimize import fsolve as fs def nonlinear(z): '''Solve a sistems 2x2 not linear ''' x, y = z[0], z[1] f1 = (x**2)+(y**2)-2*(4.41*x+2.68*y)+...
asked by 30.01.2018 / 05:06
1
answer

how to go back to a specific line of the code?

Hi, I'm working on the following menu, in which when option 1 is chosen and the patient identifier that is entered is> 3500, that error will be printed on the screen and a new identifier will be requested again I tried to do it with label and...
asked by 06.01.2018 / 11:33
1
answer

Convert to polygons and points the values of a file in Python

I have a file on my PC, text.txt that contains these values 5 0, 6 1, 5 2, 4 1 | 5 1 1 1, 4 1, 4 4, 1 4 | 3 3 1 1, 3 3, 4 1, 3 0 | 3 4 and I need to convert to polygons all the values before the symbol |, and to points the last 2 values, co...
asked by 18.12.2017 / 15:15
1
answer

How do I add text to a Text widget in Tkinter?

For reasons of simplicity, my "form" looks something like this: import tkinter as tk ventana = tk.Tk() mensaje = tk.Text(ventana, background="white", width=165, height=25) mensaje.config(state="disable") mensaje.pack(padx=0, pady=125) mensa...
asked by 28.09.2017 / 00:21
1
answer

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c: 748)

I'm using geopy in an application Python 3.6 and I have to run it on an outdated machine that uses Windows 2012 Server . The problem arises when the application calls this library ( geopy ) on this server, since it returns the fol...
asked by 04.10.2017 / 10:14
2
answers

Unify 2 functions to read files with python

Since some time ago I am trying to make a bash simulator using python, I am creating the tail and head commands, for this create 2 functions: def head(textfile): content = [] try: file = open(textfile, "r") for line in...
asked by 28.05.2018 / 21:09