Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
2
votes1
answer1015
viewsCustom window other than standard in python
hi, I would like an example of Python window, different from the pattern, as I do it ??? this is my code: from tkinter import = root = Tk() theLabel = Label(root, text="This is too easy")…
-
2
votes2
answers574
viewsHow to find out if a number is subnumber
I would like a code, with explanation (if possible of course), to know if one number is sub number of another. Example: P=101 Q=100001010057 Soon P is sub number of Q. Grateful from now on.…
-
2
votes2
answers626
viewsSeparate file lines into tokens - Python
I want to read the line of a file and store each word or information in a vector position. Ex: "18-10-2015 00092 65534". line[1] = 18-10-2015 line[2] = 00092 line[3] = 65534 OBS: tab between strings…
pythonasked 8 years, 8 months ago Jessica Costa 381 -
2
votes1
answer702
viewsHow to separate each sequence of equal numbers from a string?
How do I split a number string? For example '233' to obtain ['2','33']. Given values may vary, for example '44446' and give ['4444','6'] or '2345' and give ['2','3','4','5']. That is, give split…
-
2
votes1
answer385
viewsMultiple Python input factorial
I need to write a program in the Python language that reads multiple entries, and when receiving the "-1" input, the program prints the factorial of the respective input numbers. Detail: need to use…
pythonasked 8 years, 8 months ago Guilherme Santana De Souza 743 -
2
votes1
answer470
viewsPSYCOPG2 - Pagination
In the search for how to make paging using psycopg2 I discovered the attributes cursor itersize. and cursor., and the methodscursor.fetchmany() and scroll cursor.() I wanted to check with the staff…
-
2
votes1
answer87
viewsProblem with urllib3 and Twitter API
Save Coderos on duty I’m using this source for twitter API https://github.com/geduldig/TwitterAPI When running the error examples: File "stream_tweets.py", line 1, in from Twitterapi import…
-
2
votes2
answers1461
viewsHow to insert query result in mysql with python
I need to enter in the database the result of this query through the temperature module. The code is this. Temperature and humidity are already returning, but not saved in the database the values. #…
-
2
votes1
answer37
viewsScrapy 1.0 - Log Settings
I need to know how to change the highlighted fields, because when I run my program with Scrapy in version 1.0 it prints the result in these highlighted quantities. I wanted to know how to change…
-
2
votes1
answer379
viewsVertical crossword
Problem: Write a function called find_word_vertical that accepts a list of 2 character dimensions and a string as input arguments. This function searches the columns of the two-dimensional list to…
pythonasked 8 years, 9 months ago Inês Barata Feio Borges 313 -
2
votes1
answer318
viewsOrganize string based on numbers
I am learning to program in Python and for this I make challenges that I find on the internet in order to better fix each method, function etc This challenge consists of creating a function that…
-
2
votes1
answer75
viewsProblems with restrict_xpaths parameter in a Crawler
I have no Python experience, but I decided to try to do something with Scrapy for testing. So I’m trying to collect the existing articles on a particular page, namely a DIV element with an ID…
-
2
votes4
answers16229
viewsHow to add entries to a dictionary?
How to add user-provided entries to a dictionary? For example: Entree: 1 abcde 2 adecd 3 aaabb The created dictionary would be: dicionario = {'abcde' : 1, 'adecd' : 2, 'aaabb' : 3} or dicionario =…
-
2
votes1
answer4199
viewsHow to stop a loop using the input provided by the user?
I’m writing a program that receives entries and creates a dictionary from them. I need the loop I use to insert the entries in the dictionary to be broken when the entry is "9999", but it is not…
-
2
votes3
answers5527
viewsList in Python with non-repeated values without using set function?
How can I create a list from the sum of two previous without some value appearing repeated, without using the function set? Example: >>>a = [1, 2, 3] >>>b = [3, 4, 5] >>>c…
-
2
votes1
answer2796
viewsGlobal variable used in multiple 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 use the global variable in the 2nd function using what I…
-
2
votes1
answer448
viewsReturn list of Jsons
On the path /getAll wish to return a list of Jsons but get one 'list' Object is not callable, why this occurs and how can I return to my JSON list? Formerly, Mylist was called list and after reading…
-
2
votes1
answer396
viewsHow to Reverse Engineer MYSQL Database with Sqlalchemy?
I asked that question here at Stackoverflow the other day: How to import database to Django models? But now, I need something similar to Flask. I have a bank ready, using the MYSQL. I want to…
-
2
votes3
answers425
viewsHow to define a function that calculates the lowest speed?
The program must have a function that calculates the lowest speed among those calculated from the data provided. The user must provide as input, 9 values, of 3 in 3, which correspond to speed,…
-
2
votes1
answer182
viewsProblems with Python performance testing
A group of friends and I are starting an initiative to create a Reset on github in order to test the performance (benchmark) of http services implemented in various languages and frameworks. One of…
-
2
votes2
answers1057
viewsAdd elements to a list inside a list compreension
I have following code: myList = [1,2,3,4,5] result = [] test = [result.append(i) for i in myList] whose output from test is: [None, None, None, None, None] I’d like to know why, since ex se: test =…
-
2
votes3
answers4263
viewsParse Nfe XML in Python
I have the following code that aims to fetch a particular node of an XML Electronic Invoice, but without success. I tested with other Xmls and it worked. import xml.etree.ElementTree as ET tree =…
-
2
votes1
answer175
viewsDictionary with lists as value
I have 2 lists like the following: lista1 = [ {'Idade': '8', 'Especie': 'Gato', 'Nome do Animal': 'Felix'}, {'Idade': '57', 'Especie': 'Tartaruga', 'Nome do Animal': 'Michelangelo'}, {'Idade': '12',…
pythonasked 8 years, 7 months ago Força Chape 349 -
2
votes1
answer728
viewsDictionary, separate values and keys into two lists
I have the following dictionary: abc = {'y': 'Y', 'b': 'B', 'e': 'E', 'x': 'X', 'v': 'V', 't': 'T', 'f': 'F', 'w': 'W', 'g': 'G', 'o': 'O', 'j': 'J', 'm': 'M', 'z': 'Z', 'h': 'H', 'd': 'D', 'r':…
pythonasked 8 years, 6 months ago Alberto Pimenta 169 -
2
votes0
answers552
viewsSynchronization of threads in python
I am making a program that should simulate the synchronization of files between two threads, however, I do not know much the python language. I have already created the threads, lock methods and…
-
2
votes1
answer590
viewsPython -->Valueerror: incomplete format
Can someone help me with this code? I have two problems: The first is the error mentioned in the title and the second is the vector of the function, which does not receive attribution (when I went…
-
2
votes1
answer470
viewsBlueprints - what is the concept? for what?
As I voted for Flask(python), I now see so many examples using Blueprints. What are they? What are they for?
-
2
votes1
answer56
viewsWhen I edit a spreadsheet with pyexcel it loses its appearance
Hello, when I try to add new values in a spreadsheet ods she loses all her "style" and keeps only the values. Follow the code: import pyexcel sheet = pyexcel.get_sheet(file_name="dados.ods")…
pythonasked 8 years, 5 months ago mrlucasrib 641 -
2
votes1
answer106
viewsHow can I use Django 1.9.6 within my virtual environment?
I’m trying to use version 1.9.6 of Django in the virtual environment 'myvenv' that I created through the Ubuntu terminal, but even after having done the installation through the command pip3 install…
-
2
votes1
answer50
viewsOrdering dictionary by obtaining values
I have the following function that I have done which is this : def funcao(elemento): x = [] for i in grafico: timestring = i["CrimeTime"] x.append(timestring) x= sorted(x) y= Counter(x).values()…
-
2
votes1
answer235
viewsDistance count between one element and each other in a list (Python)
I have a list that symbolizes a timeline: linha_tempo = [1107, 1107, 0, 1104, 1104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1106, 1106, 0, 0, 0,…
-
2
votes1
answer229
viewsConversion of response to lists
I am having a small problem in my algorithm I have to receive a "name of an institution" any typed by the user and convertlist to use it in future other conditions but it is converting to string all…
-
2
votes1
answer552
viewsDictionaries receiving list with values
My code is having some small problems, it receives "institutions" (names that the user wants in the input) inside a dictionary this input is passing pro dicionario as a list, and then I use the list…
-
2
votes1
answer955
viewsMake 1 figure with 3 graphs
I have 3 functions like the following that allows to obtain each one a graph and I want a function where use the 3 graphs of the other functions to join in one figure. def funcao1(grafico): ...…
-
2
votes1
answer243
viewsInfinite loop in exercise using classes
I’m doing an exercise in Python, which is a game using classes. It happens that when it arrived in the room "Escapepod()" and I select the correct POD, the looping becomes infinite, not knowing the…
-
2
votes1
answer401
viewsCreating data set for sklearn with dataframe pandas
I have the following situation from sklearn.linear_model import LogisticRegression import pandas as pd x = pd.DataFrame({'A':[1,3,8,6,1],'B':[2,6,9,3,2]}) y = pd.DataFrame({'C':[8,6,3,6,1]}) How do…
-
2
votes1
answer578
viewsCompare fields in two datasets
Considering two sets of read data from type files *.CSV with the Pandas. Each set has only one field CPF Favorecido,where there are millions of records. Each data set is equivalent to one month. I…
-
2
votes1
answer86
viewsConvert to list a string from a list that contains Base64?
I receive through a requisition json one request.POST that comes as a list of string Base64. I can convert to string with str(request.POST['imagem']) what results something like this:…
-
2
votes0
answers548
viewsAndroid client communication with Python server
I have an extremely basic server in Python and an Android client, but I can’t establish the connection. I have a client also made in Python and other in Java, and both connect perfectly to the…
-
2
votes2
answers29234
viewsCreate . txt file in PYTHON if it does not exist
The code: arquivo = open(input('Nome do arquivo a ser editado:'), 'r') texto = arquivo.readlines() texto.append(input('Insira o texto:')) arquivo = open(input('Nome do arquivo a ser editado:'), 'w')…
-
2
votes0
answers145
viewsInterface between python and Prolog
Good morning. I need to make the communication between Prolog and Python. I ended up finding a pySwip api that interface between these two technologies, but I can’t make it work because Prolog needs…
-
2
votes2
answers535
viewsDjango Custom Template Tags
Good afternoon, recently I have a problem in the Django framework, I have a problem in my custom template tag, I do the method in a.py file call it in the templates and does not display the result I…
-
2
votes1
answer83
viewsIn python, how can I simulate a read-only property in classes?
I would like to know how I can simulate a read-only property on Python. For example, I have the following code: class IPInfo(object): def __init__(self, ip): self.ip = ip; ip = IPInfo(object) ip.ip…
-
2
votes2
answers256
viewsInsert Into Array Problem
Good, I’m trying to learn python because it seems to me a language with some applicability interest in the most diverse areas (and interest me for Raspberry). As I learn I like to develop something…
-
2
votes2
answers245
viewsignore in function call if empty
suppose I feed a function with a tuple: a = ['c:/', 'd:/', 'x:/', 'y:/'] b = ['c:/data', 'd:/data'] funcao((a, b)) however if you have an empty list you would like it to be ignored as an example:…
-
2
votes0
answers139
viewsRFID-RD522 with Python
Good morning guys!! I’m trying to connect a module RFID with PYHTON in the Raspberry B I followed the following tutorials:…
-
2
votes1
answer1327
viewsCompare values of two arrays
Hello I need to compare 2 values of 2 arrays, but I’m not if succeeding: plan = [{'Cod': '11518', 'qtdPallet': '176', 'qtdLastro': '22', 'qtdCx': '12', 'Prod': 'Exemplo1', 'FC': '1'}, {'Cod': '972',…
-
2
votes1
answer410
viewsDisadvantages for Brazilians to use the Google App Engine
I’ve done some app and some testing with Google App Engine. I’ve read about several of your limitations, and some of them are a little bit boring, but nothing that worries me too much, because as I…
-
2
votes0
answers1234
viewsRemoving the background of an image - python
I’m developing a code to remove the background of an image, I’m trying to use the Canny border detector to elaborate a mask and try to remove a piece of pipe from the image: The code I’m working on…
-
2
votes1
answer203
viewsPython - PHPSESSID
Well I’m trying to create a script who enters a website without having to log in through the library requests. I want to do it using the PHPSESSID. How can I do this?…