Questions tagged as 'python-2.7'

1
answer

Sort TXT lines in numerical order

I need to invert all the columns of my txt file, using python. Txt file (example): Regra n10 - exemplo Regra n9 - exemplo Regra n8 - exemplo Regra n7 - exemplo Regra n6 - exemplo Regra n5 - exemplo Regra n4 - exemplo Regra n3 - exemplo Regra n...
asked by 29.05.2018 / 16:22
2
answers

What's wrong with this line of print = ('Hello,' + full_name.title () + '!')? [closed]

I'm new to programming and I'm following the exercises in Eric Matthes's book. In the text editor, I typed print = ('Hello,' + full_name.title() + '!') and an error message appeared.     
asked by 17.05.2018 / 03:58
1
answer

Tuple ordering exercise

I'm catching up on a Python exercise. It asks for the following:    Create a function that:       Get a list of tuples (data), an integer (key, zero by default) and a boolean (reverse, false by default).    Return data sorted by the item i...
asked by 10.03.2018 / 17:14
1
answer

how to disappear CMD window after using os.system in python

I have a code in Python 2.7 that opens a PDF with os.system('meuarquivo.pdf') and it opens up right. However when opening the file it also opens an empty CMD window. Is there any way I can close this window or prevent it from appearing?...
asked by 27.12.2017 / 17:00
1
answer

Web application for script monitoring

What is the best way to monitor script execution? I have a script.py that needs to be running "infinitely", and I'd like to know if it's running or not. I would like a web application to do this monitoring, and if it closes, I can run it through...
asked by 20.12.2017 / 19:53
1
answer

Django periodic checks

How could I create a loop, thread or anything that my webapp periodically checks every 5min the database and exclude entries that are "due." I researched but did not find anything specific. I even found something saying that you should create...
asked by 10.11.2017 / 21:12
1
answer

Insert data tuple into the same database cell

I have the following script: import pymysql cobertura = (10, 20) base_de_dados = pymysql.connect("localhost", "root", "senha", "base_de_dados") cursor = base_de_dados.cursor() cursor.executemany("INSERT INTO individuo VALUES (NULL, %s)", (cob...
asked by 11.10.2017 / 19:57
1
answer

Identifying the most efficient method of identifying the central element of an array

I have the following algorithm: import numpy as np matriz = np.array(np.zeros(81).reshape(9, 9)) for i in range(1, matriz.shape[0], 3): for j in range(1, matriz.shape[1], 3): matriz[i, j] = 255 print(matriz) It generates the...
asked by 23.09.2017 / 16:52
1
answer

Add 0 after the comma

I have a string str(owner.Vr_real).replace('.',',') that receives values of type: 2045.5 3040,45 4042,05 Notice that the first number does not complete with 0 (ex: 2045,50). What function could I use to add 0 to the end? I tr...
asked by 19.09.2017 / 23:26
1
answer

ImportError: No module named gerencia.alert.views

I'm trying to use the following function defined in gerencia/alert/views.py def maLogger(level, message, node=None): aux=0 if level=='Critical_client': aux=2 date = datetime.datetime.now() log = Log(level=level, dat...
asked by 23.08.2017 / 05:46