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
-
3
votes0
answers155
viewsHow do I connect my Python code to a game or program?
Hello! I started studying Python and saw in it some possibilities to do some hacks for games and I liked the hahaha language even more. I have a code that for example, takes a String and converts it…
pythonasked 9 years, 4 months ago Conrado Saud 107 -
3
votes1
answer108
viewsWhat tools to use to create WEB games?
I would like your help in the following questions: 1. What better option for web game development ? 2. HTML5 with Canvas, Javascript and PHP ? What do you think of this combination ? 3. Python is an…
-
3
votes2
answers1883
viewsHow to remove spaces at the beginning and end of an XLS output
I have the code below, for him to open a spreadsheet on XLS and show me the header. however I would like the left and right spaces to be removed and the internal spaces to be replaced by underline…
-
3
votes1
answer257
viewsCreation of Graph in Dictionary form returning integers
I am implementing a Python code for Graph creation with open (filename, "r") as f: d = {} for line in f: key, value = line.split() if key not in d: d[key] = [value] else: d[key].append(value)…
-
3
votes1
answer419
viewsHow to select Count(*) with Python and mysql.Nector
The library I’m using is that one. That is the code: cur.execute("""SELECT COUNT(*) as total FROM tabela as t WHERE ... """, (v1, v2)) for (total) in cur: if total > 0: print('Existe') The…
-
3
votes1
answer649
viewsDifference between Father. __init(self) and super(Father, self). __init__()
I have a little doubt about the issue of inheritance in python. In the following test, I hoped that quack prints the same value for the two classes I created: class A(object): a,b = (None, None) def…
pythonasked 9 years, 4 months ago Wallace Maxters 102,340 -
3
votes1
answer1467
viewsUsing recursion to count the number of times a number appears in a list
I created a recursive algorithm to count the number of times a certain number n appears in a list ls. It seemed to work if the list ls is quite small (between 10 and 100), but if it’s big, like…
-
3
votes2
answers5642
viewsHow to access variables present in different functions?
What is the best way to access a variable that was created in a function? For example: def Luggage(): mala = [] take = raw_input("O que você deseja levar na sua viagem?") mala.append(take) In case I…
-
3
votes1
answer3024
viewsHow do I use the if and Else functions?
I’m having trouble with my job if and else, I started my programming studies a short time ago and didn’t understand very well how to use. It’s something like that? número = 2 If número == 2:…
-
3
votes2
answers254
viewsSIT tones using Python or C#
Hello, I’m making an app that detects SIT tones (https://en.wikipedia.org/wiki/Special_information_tones). I understand very little the mathematics involved in Fourier transforms and signal…
-
3
votes1
answer121
viewsEdit widgets Django
Hello! I’m developing a Django app. On the project registration page appears a Selectmultiple pro user select the participating teachers. But on the details page I just wanted to appear the names of…
-
3
votes2
answers331
viewsI cannot enter user-defined values in Sqlite
I have a problem where I can not add anything in the table and always appears the error: sqlite3.Interfaceerror: Error Binding Parameter 0 - probably Unsupported type. The code I’m trying to add…
-
3
votes2
answers1014
viewsWhat is the data obtained by scipy.io.wavfile read?
Hello, I have been using scipy.io.wavfile.read to open the audio files made available on: https://en.wikipedia.org/wiki/Special_information_tones. I convert the files to wav using VLC. In theory the…
-
3
votes1
answer726
viewsPython Tkinter text widget in another setting does not allow Insert
I am new to programming and python. I would like to insert a definition a box information that was created in another definition. How is that possible? According to the code, which is attached, the…
-
3
votes2
answers928
viewsTypeerror: Incorrect padding
Guys I’m trying to decrypt AES, only I’m facing the following mistake: Traceback (Most recent call last): File ". /teste2.py", line 190, in main() File ". /teste2.py", line 186, in main…
-
3
votes1
answer736
viewsYou can access the key through the value:
In dictionaries, in Python, is it possible to access a key through the value? Is there any method that inverts key/value?
-
3
votes2
answers467
viewsIterate a list inside a switch
good guys I would like to know how I do to iterate a list on a switch in python, type I have a list with ten values lista = [1,2,3,4,5,6,7,8,9,11] now I want to access this list value by value and…
-
3
votes2
answers300
viewsHow to insert checkbox dynamically from Python/Flask code?
I am trying to create a script in Flask and came across the following situation: I have in my code a for that sweeps the subdirectories of a root directory: for root, dirs, files in…
-
3
votes1
answer854
viewsHow to calculate test scores?
I’m writing a code that prints a student’s grade according to the number of questions he gets right. But I need the program to do the calculation in a specific amount of times. The program must…
-
3
votes3
answers479
viewsMaximum occurrences in a python dictionary
If I have the dictionary: meu_dic = {A:3, B:5, C:0, D:10, E:2} resulting from: meu_dic = {i:lista.count(i) for i in lista} I know that To appears 3 times in the list, B 5 times, etc.. How can I…
-
3
votes1
answer1218
viewsFind out if a point is within a circle on a Cartesian plane
I was doing the task Target shooting of the 2013 Brazilian Computer Olympiad (OBI) at Programming level 2, which can be found here, and I was able to do it without great difficulty. The task was to…
-
3
votes1
answer669
viewsHow do I click an image and perform a function
The language is python and the graph is Qt4. I have a qlabel and a hidden widget. I need that when the qlabel is clicked the widget appears, and when it is clicked again it disappears. I researched…
-
3
votes1
answer309
viewsInformation contained in two Scrapy pages
I’m not a python programmer, but I’m trying to work with the Scrapy application. The above example is what I need, this runs in extension of Chrome. To explain, I need the post and all available…
-
3
votes1
answer206
viewsCheck current index and next index equal to zero python
I need to scroll through a list in Python as for example: l = [2313, 1221, 1333, 66, 0, 0, 0, 0] I would like it if the current element and the next on the list are zero replaces the current and…
-
3
votes1
answer8603
viewsGrouping and aggregating data
I have the following file on CSV (12 Millions of records): UF Municipio Cod NIS Valor Data MA IMPERATRIZ 803 16361947271 45.00 01/01/2011 MA IMPERATRIZ 803 74629273937 15.00 01/01/2011 BA RUY…
-
3
votes1
answer1642
viewsImport: cannot import name Patterns on Django
The application on Django was working normally until I went to put Django-comments, first I installed it with the setup.py that came along, I believe that is what is causing the problem, then I put…
-
3
votes1
answer57
viewsStatistics of battery battery life in python
I have this battery usage data from my phone that I captured using Tasker: 97 - 1467514184514 tela desligada - 1467514366535 tela ligada - 1467514369196 96 - 1467514414616 95 - 1467514674523 94 -…
pythonasked 8 years, 9 months ago Filipe Teixeira 502 -
3
votes1
answer123
viewsIdentifying a person through rules (MI)
I need a system that identifies a person (exactly a person) through rules (in this case, such a person’s habits) but my knowledge of AI is very shallow. Is there any appropriate technique for this?…
-
3
votes3
answers72
viewsMake copies of lists at certain positions with Python
Hello, please, I would like to copy a certain list in python. The total list size is 150 and I wish to remove the last 50 elements from the list. Here I will represent a list 100 times smaller, ie…
-
3
votes2
answers1609
viewsRandom distribution in lists with python
I have a list: li = [0, 0, 2313, 1221, 0, 1333, 66, 0, 0, 0, 0] and another list of lists, where: The list of lists is called disciplines (below). The lists that are within disciplines, are also…
-
3
votes1
answer867
viewsReal-time window update problem
Hello. I am creating a program that allows the user to know which note is singing and its frequency, in real time. However, during the window update, the program stops working and only updates after…
-
3
votes1
answer881
viewsNested Functions in Python
How do I do nested functions in Python? Another question, because I always need to use the self parameter, and I’ve already put parameters in the function? For example, it is considered that the…
-
3
votes1
answer179
viewsSending attachment with Flask-Mail
Setting up flask and testing was quick and easy but sending attachments is very difficult if not impossible. Someone has a tip or example for sending attachments with Flask-Mail? My code is like…
-
3
votes3
answers1598
viewsCountdown by using Tkinter
I’m trying to come up with a Tkinter show to count backwards. I can’t understand why I can’t take Entry and turn it into an integer. (As this is just a test, I did using Portuguese same) from…
-
3
votes3
answers6679
viewscreating a python voting bot
import requests dados = {"action": "polls", "view":"process", "poll_id":"2", "poll_2":"6", "poll_2_nonce":"e29cc82a53"} url = "http://soulegal.byethost7.com/wp/wp-admin/admin-ajax.php"…
-
3
votes2
answers591
viewsStart a command line tool in Python
How can I create a command line tool in Python that works like ls linux or dir windows? How would I start one script like the one that will later be compiled as an executable?…
-
3
votes1
answer4136
viewsHow to convert color image to black and white and highlight only the white of a video
I would like to highlight the white color using webcam and opencv python, however my image is colored, first I need to convert to black and white and then I would like to highlight only white, which…
-
3
votes2
answers507
viewsIncrement in Python list
Hello, I am creating a script to do automatic logins on equipment. I have created a list with several Ips that are the equipment I want to access. I want to create a loop, I tried with while and…
pythonasked 8 years, 9 months ago Cristhian Miguel 207 -
3
votes1
answer624
viewsIs it necessary to close Mongodb connections with Pymongo?
I am working on a REST API with Python (Flask + Mongodb) and during development I checked that, nowhere in the code, had I released the resources from the database. I have researched around but…
-
3
votes2
answers1042
viewsPython - Selenium send_keys() does not work in this form field
I made the correct identification with xPath, the software . clear() works perfectly, however send_keys does not work at all. Follow the HTML code of the form: <input id="yui-gen19"…
-
3
votes1
answer229
viewsIDLE: Your Python may not be configured for Tk
I’m trying to use Python in Slackware, in Ubuntu I know how it is, but in Slackware I couldn’t. When I type in the terminal idle to open Python, the following message is displayed: Your Python may…
-
3
votes2
answers2527
viewsHow to import Python libraries that are in another hierarchy?
I have the following directory structure src\ conectores\ mysql.py bibliotecas auxiliares teste\ chamarMysql.py In the above structure as I can from inside the test file call Myql.py, call a class…
pythonasked 8 years, 7 months ago Fábio Jânio 3,407 -
3
votes1
answer706
viewsHow to monitor changes in a folder?
How can I monitor and capture changes in folders and files? I intend to use this as part of a service that starts with the system the script would be in .pyw. example: if(mudou != padrao): pass…
-
3
votes2
answers466
viewsChanging Key in Windows 10 Registry
The code below is giving "Registry error", that is, it does not create the key in the Windows registry. Does anyone have any idea how to resolve? import socket import time import subprocess…
-
3
votes2
answers297
viewsList Comprehension for this case
How can I use comprehensilist on for that case: >>> a = 'A' >>> lista = [1, 2, 8, 5, 10] >>> l = [a, num for num in lista if num%2 == 0] File "<stdin>", line 1 l =…
-
3
votes3
answers102
viewsValueobjects Django
Good morning guys, I’m starting now with Python and Django and I came up with a question in the creation of my models. I’d like to create something like: Person(models. Model) Name ... Address…
-
3
votes1
answer860
viewsHow to send multiple requests at the same time
Well my program takes Urls from a text file, enters them and checks if it has a certain text in its HTML code, it would be possible to read all lines of the file, and instead of making a request at…
-
3
votes0
answers319
viewsPython ticket control script
What would be a more appropriate solution to this problem? The purpose of this Python script is to process possible ticket sales, analyzing each of them, indicating whether it is possible to SELL or…
-
3
votes2
answers4139
viewsProgram that uses input(). split(" ") and does not run in Python 3.5.1
I have to do several exercises in Python that the input values should be on the same line and indicated me the input().split(" "), but the program does not run, error. Ex.: C, Q = input().split(" ")…
pythonasked 8 years, 7 months ago Ilda Mendes 31 -
3
votes1
answer1594
viewsFind the sum of the elements of a matrix
I was trying to create a code that would create a square matrix from the side n and then summed up each side to find out which has the different sum, in the sum part I was half locked. I tried to…