Questions tagged as 'python'

1
answer

Problems executing commands in CMD with Python

I am not able to execute (or get the result) of commands executed in Windows by Python. I got a code sample I saw on various sites and answers in the OS, but none worked well for me. import subprocess # Exception: [WinError 2] The system cann...
asked by 25.08.2016 / 23:09
1
answer

REGEX - extract part of the text in a string

I have the following string == > "the guy with the mush he hit with the car in the car of so and so" I'm trying to extract starting from ^ ("the guy ...") and ending in ("... the car") $ Can someone help me with this RE     
asked by 10.06.2016 / 01:53
2
answers

MySQLdb - insert value of a variable in the database

I am experiencing problems when trying to insert the values of my variables into the database I am trying to do as follows import MySQLdb id = 4 idade = 18 nome = 'cebolinha' email = '[email protected]' db = MySQLdb.connect("localhost","dev...
asked by 10.06.2016 / 18:14
1
answer

problem inserting unicode value into database

I'm breaking my head with this since yesterday I've done everything to insert the value in utf8 but it is not working and the following I have this code as an example #!/usr/bin python # -*- coding: utf-8 -*- import MySQLdb db = MySQLdb.conn...
asked by 11.06.2016 / 22:31
2
answers

Count occurrences in tuples

I have a problem that is simple but I am not getting the solution. I have a list of tuples, for example: lista = [('x',2,3),('y',4,5),('x',6,7),('z',8,9)] What I want is for him to tell me how many times x , y and z a...
asked by 13.04.2016 / 19:23
1
answer

Global variable used in various functions

I have this code: donos=[] def calcula_media(): lista_dicionario= [1,2,3] donos.extend(lista_dicionario) def funcao2(): print donos How can I do to use the global variable in the 2nd function using what I used in 1º to make i...
asked by 28.04.2016 / 22:25
2
answers

Ping manipulation in Python

I am creating a code that pings a list of ips. I got it to drip and give me the answer, but I can not do the condition I want, which is: SE ping ok: continuar os comandos SENÃO: faz outra coisa. I do not know how to manipulate the pin...
asked by 18.07.2016 / 18:11
1
answer

404 when setting an app.route in Flask

I have this simple code available on the Flask page: from flask import Flask app = Flask(__name__) @app.route("/") def hello(): return "Hello World!" if __name__ == "__main__": app.run() When you upload the Service, everything wor...
asked by 14.07.2016 / 22:25
1
answer

How to supply a specific amount of strings to be tested?

I can test whether a user supplied string is a palindrome or not (word or phrase that can be read backwards ignoring spaces and uppercase and lowercase letters, for example: Help me get on the bus in Morocco), using the code: string = raw_inpu...
asked by 28.03.2016 / 23:58
1
answer

Return list of JSONs

In path /getAll I want to return a list of JSONs however I get an object is not callable , why does this occur and how can I return to my JSON list? MyList was called list and after reading the following definition of callable the e...
asked by 27.03.2016 / 21:57