Questions tagged as 'python'

2
answers

Can you return a print or a message in python?

If in a function I can return a print or the message itself that they ask me to give, the exercise says that if the number is inside the list it must tell the user that such a value is in the list and the same in case opposite. def comprobarEn...
asked by 21.10.2018 / 01:35
1
answer

Save file to directory, from the view - Django

I have an application with which I upload files, and subsequently those files are consulted; the files have the following nomenclature: EXAMPLE_7777_AAAA.pdf If the file belongs to group 7777, the file is saved in the path: upload_to = 'Files...
asked by 14.08.2018 / 21:08
1
answer

Print a n amount of data from a PYTHON csv file

I use this code to read the csv file, but I just want to extract a part of all the data. with open('val.csv') as csvarchivo: entrada = csv.reader(csvarchivo) for reg in entrada: print(reg) Result: of the 100 data, for exampl...
asked by 07.08.2018 / 19:18
1
answer

Convert timestamp to dd / mm / yyyy and add Timezone to Dataframe Panda

I am loading information into a DataFrame of the Python Panda module, where I have a timestamp type record, that information is brought from MongoDb cursor = collection.find( { "sono" : str(sono), "time" : { "$gt" : int(start) }, "time" :{"$l...
asked by 16.08.2018 / 21:36
1
answer

Validate string format "Latitude, Longitude"

I have an entry type user control, and I would like the user to only be able to enter the following format: Latitude, Length as for example "12.2323, -1.53452" That is, you can only enter numbers, periods, 1 comma, and the minus sign. On t...
asked by 17.08.2018 / 17:54
1
answer

Return value of a Python class

I am a little new in this of the classes and objects. I have a small problem I have created a class that receives data from a file that I use as a dictionary so that in another program equal in Python I can translate the data from a 4GL to...
asked by 18.10.2018 / 20:09
1
answer

Problems dividing an image into squares in python

I'm trying to crop an image using python, but I do not understand why this code gives an error: imagen = PIL.Image.open("imagen-entera.jpg") ancho = int(imagen.size[0]/8) alto = int(imagen.size[1]/8) for si in range (8): for gh in range (8...
asked by 05.08.2018 / 19:35
1
answer

How to recover a field from a foreign key, to be used in another form without modifying the field to recover?

I have the following graphical interface Where I want to unsubscribe a product, retrieving the code in the new "Submit Low" form. This is my code Code models.py class venta(models.Model): codigo = models.IntegerFi...
asked by 26.07.2018 / 16:57
1
answer

Do not place the message correctly in python

I want that when the user enters one of those numbers, the corresponding message appears, but this way a "4" appears in the Run current file of sublime text 3 number = 8 guess = 4 if str(input("4")): print("Seleccionaste el numero...
asked by 18.07.2018 / 23:39
1
answer

send value to a Qwidget from a different Python class

How can I change the value of a Qwidget from another class? Example: class Primera(QMainWindow): def __init__(self): QMainWindow.__init__(self) uic.loadUi('task.ui',self) self.label_1.setText('linea1') class Se...
asked by 31.07.2018 / 04:33