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
-
1
votes0
answers58
viewsHow to dynamically define the function to be called in Python
Hello, I would like the program user to write a function for later use, however I’m having difficulty to implement this: See the example below: def funcao_integracao(x): y=x**2 return y def…
-
1
votes0
answers16
viewsCollect value from a dictionary
I’m in a project where inside the dictionary the key is a person name and its value is list. The list has values filled in as shown in the example: Ana:(3,5) - "Ana" is the key of the dicio and…
-
1
votes1
answer58
viewsFind values in blocks that extend across multiple lines
I have a Arquivo Espelho that contains coupon mirrors, and I created an algorithm to separate the coupons: import re txt = open("arqEspelho.txt", 'r+').read() x = re.finditer(r".*COTIA\s*C*", txt) z…
-
1
votes0
answers84
viewsRequests does not download files > that 4MB
I’m using requests in python, and I can’t download files larger than 4mb (maybe a little smaller too). I am downloading some PDF, and I can download small files normally, but when I use a slightly…
-
1
votes1
answer125
viewsFunction Returning Multiple Values in Python 2.7
It’s my first post on this forum, so I apologize in advance for any etiquette error. I’m trying to implement a function in Python 2.7 that returns me a random element from a list or a sublist of…
-
1
votes1
answer66
viewsFind equal names(string) in two distinct dataframes and add a column in the second data frame with another data from the first
Hello. I have two data frames: Times with 629 lines. rank prev_rank name league off def spi 0 1 1 Manchester City Barclays Premier League 3.34 0.24 95.24 1 2 2 Liverpool Barclays Premier League 2.95…
-
1
votes0
answers39
viewsDoubt in dictionary - Python
Good morning! I’m trying to create a dictionary where it has some keys inside other keys, and each key contains more than one item. I have looked in several places but I can’t find anything about…
-
1
votes1
answer43
views'End of statement expected' pyCharm error
I have a very simple method, which takes a Boolean parameter and changes a global one to the negated value of the parameter. However, using the Pycharm IDE, it returns an error in the snippet global…
-
1
votes1
answer215
viewsReplace letter by position
I’m doing a simple python hangman game and I’d like to know if you can replace it by the letter position. Type I want at position 1 '*' to be replaced by the letter I want. Code: palavra_secreta =…
-
1
votes1
answer54
viewsCan a local chatbot be considered a P2P system?
At first I had made a chatbot that connected to Telegram, but as the message goes through a server I believe that it does not characterize as a p2p system (client, client). Then I made a chatbot…
-
1
votes1
answer405
viewsSimulate click touchscreen in python
I need to create a python function that can create a click holding it while a second click is started and finished during the duration of the first. Using the mouse, this is not possible, however,…
-
1
votes0
answers33
viewsDo you have any python library for creating an online game? The idea is Tetris in pygame, in q in it you can fzr a X1 with someone on another pc
My idea is that the two X1 screens, appear to both players, that they can see each other’s moves in real time. I couldn’t find anyone who knows a library like this or who can teach you how to use…
-
1
votes1
answer35
viewsGame does not recognize keyboard input by "pynput"
I’m creating a bot to press the "A" key inside a game. Code I am using: from pynput.keyboard import Controller; from time import sleep; keyboard = Controller(); sleep(2) keyboard.press("a");…
-
1
votes0
answers47
viewsHelp with re.search function
I have a for who plays at a dictionary to check what the user typed to see is the same, to call a function... the case at issue: FOR for x in abrir: if(re.search(abrir[x], user_response,…
-
1
votes2
answers179
viewsEncoding problem while extracting zip file - edited
A webhook calls my API by sending a POST request. On the request body contains the url of a ZIP file. Using the requests library, I perform a GET at the file url. I need to extract this few files…
-
1
votes1
answer1046
viewsHow to filter lines that have a certain string?
I know that the command dados[dados.Value == 'disease'] only the lines where the value of the column "Value" is exactly equal to the string "disease", but I need to select all the rows in the column…
-
1
votes0
answers41
viewsSearch number in Python text
I developed a python code to search for number inside an excel file, where it has about 40 thousand data. I made a rule to bring myself only number 9 to 14, where I would classify it as phone.…
pythonasked 4 years, 11 months ago user162978 -
1
votes1
answer33
viewsClick on a button inside the power bi with python
My dear, I need my robot to click the button inside the power bi to upgrade, for it to upgrade alone, just missing this part so it gets 100% import os import pyautogui import time…
-
1
votes2
answers53
viewssaving Dict list on file
I have a function that saves a Dict in a file, but this is simultaneous, I mean, every time I have a new Dict. I couldn’t apply the concept of append to this problem. The Archive is being saved this…
-
1
votes2
answers149
viewsHow to extract only words from any text, ignoring punctuation and uppercase letters?
Be the text below: This is the most favourable period for travelling in Russia. They fly quickly over the snow in their sledges; the motion is pleasant, and, in my opinion, far more agreeable than…
-
1
votes1
answer303
viewsUsing resample on pandas with intermittent date variable
I have a database in which one column is the year and the other columns are the total of formal workers in a city (each column a city). My goal is simply to aggregate my annual data to triennials.…
-
1
votes0
answers13
viewsIn python how I read typed data on the same line and assign the variables
I need to read 3 typed data on the same line and insert in three different variables used python.
pythonasked 3 years, 4 months ago Rogerio Freitas 11 -
1
votes3
answers450
viewsRename files and move out of the Python directory
i am developing a python script, which he needs to access a folder and within that folder has 3 folders which has several files example: Pastaprincipal | | ---- pasta1 | ---- arquivo.pdf | | ----…
pythonasked 4 years, 11 months ago user172242 13 -
1
votes0
answers36
viewsList indexes
Good afternoon, this week my teacher passed me the question of scheduling a phone book. I did with dictionary but he had me redo with lists. There’s a part where I have to remove a contact from the…
-
1
votes1
answer226
viewsWhat is the equivalent of Seaborn’s```argument in matplotlib?
When I want the points belonging to different categories to be colored each of a color in the seaborn, i simply put the categorical variable of interest as argument value hue. Replicable example:…
-
1
votes1
answer111
viewsProgram to check number of words and a sentence of a text file
text file used: https://easyupload.io/j5agtq The method is part of a class called Arqtext Objective: The method does not use input and returns, in a tuple object, (1) the average number of words per…
-
1
votes1
answer432
viewsGUI automation with python
Next, I want to start a project to create a bot for a specific android game in python, for this, I use an emulator, Nox. My idea is to be able to work with the automation part of Gui (automatic…
-
1
votes1
answer500
viewsMultiple connections via rtsp using Opencv and Python
I recently made a basic Python script using the Opencv library for recognition using security cameras, but I realized that for some reason, I can’t open two or more connections on the same camera,…
-
1
votes1
answer654
viewsHow to record speaker and microphone sounds simultaneously with python in windows?
I tried to record the sound of the desktop with the pyaudio, but I can only hear the sound of the microphone or speaker. I also downloaded the portaudio, but I’m not sure I can get the sound of the…
-
1
votes1
answer114
viewsHow to pass a function as an argument in Python?
I tried it in various ways, using local variables and assigning them the two methods but it didn’t work, does anyone know where I went wrong? def game(init, loop, frame_rate=60): from time import…
-
1
votes2
answers7068
viewsHow to get out of one loop inside another through a function in python?
Hi, I’m confused and I’m not getting my code right. What I need is to get out of all the loops through the function ask_continue() after the user responds n input without leaving the program,…
-
1
votes0
answers327
viewsPython Psutil - check PID execution
Good Morning! I am mounting a script in Python to monitor a certain windows task by PID, for this I am using the Python Psutil library. The problem is that whenever I run the code it brings the…
-
1
votes1
answer1279
viewsReferencing Variables in Python Imported Functions
I am learning Python on my own and in many videos and subjects programmers advise and emphasize the importance of "clean and organized codes". So I’m trying to create classes and functions in…
-
1
votes0
answers38
viewsHow does Pickle behave with stored variables? (Python)
I’m learning Python on my own and now I’m practicing the Pickle module. I managed to make it work normally, but it occurred to me a question about what happens when I store a variable in the pickle…
-
1
votes1
answer197
viewsI have a neural net, and now?
Hello, I made a neural net watching a video class on, the code is very simple but functional. And open a csv file, sort the data and do the training, right after the test is done and the result is…
-
1
votes0
answers164
viewsPython Telegram Bot - I can’t send photos
I just started programming, so maybe it’s something simple. Anyway, I made a bot on Telegram to simulate a Pokemon hunt. I’m trying to implement that the bot sends a photo of Pokemon when the user…
-
1
votes1
answer57
viewsNested Relationships
Guys, I have a question regarding the nested relationship. When my code gets that way: class CategoryListSerializer(ModelSerializer): class Meta: model = Category fields = ['id', 'name',…
-
1
votes2
answers93
viewsHow to create multiple columns using the values of one in pandas?
I have the following code: df = pd.DataFrame(repeat_R) print(df) The dataframe I have is like this: 0 0 0.583822 1 0.582975 2 0.541191 3 0.526122 4 0.547239 5 0.555875 6 0.556838 7 0.524316 8…
-
1
votes1
answer73
viewsDisplaying the tags of a web page with indentation proportional to the depth of the element in the document tree structure
Issue: Develop the Myhtmlparser class as an Htmlparser subclass which, when fed with an HTML file, displays the names of the start and end tags in the order they appear in the document, and with a…
-
1
votes2
answers16
viewsHow to enable firefox extensions in Selenium?
I installed an extension in firefox but when Selenium opens firefox it starts without the extension, is there any way that Selenium can start firefox with the extension that is installed or make it…
-
1
votes1
answer21
viewsPython Pandas - Conditional partial dataframe string
I have the following situation: I own a dataframe: data = {"Id": ["01", "02", "03", "04",'05'],"Fruta": ['Maçã','Abacaxi','Banana','Laranja','Morango']} base_dados = pd.DataFrame(data)…
-
1
votes1
answer320
viewsHow do Tkinter wait for user interaction during the script?
I am learning Python on my own and now I took it to learn GUI in Tkinter. If anyone can help me, I’m having trouble getting the program to display a greeting and then offer options on different…
-
1
votes0
answers851
viewsPocketsphinx voice recognition - Python 3.5
I am doing voice recognition with the modules pocketsphinx and Speech recognition, but when I went to make the code available offline, the program returns the following error: Traceback (most recent…
-
1
votes1
answer510
viewsHow to change location buttons dynamically using Tkinter?
I know that this code has a lot of repetition and I intend to "dry" it later. For now, I want to understand how to change the position of the buttons in Tkinter dynamically. The solution I initially…
-
1
votes1
answer554
viewsCalculation of salary needs to limit houses
An employee of a company receives salary increase annually: It is known that: This employee was hired in 1995, with initial salary of R $ 1.000,00; In 1996 he received a 1.5% increase over his…
-
1
votes1
answer637
viewsHow to access data in json and save to a variable in python? flask-api
I am making a very simple Flask Api, I will receive a title and a body in json.. { "title":"Test", "body":"test" } My app.py class is like this from flask import Flask, request, jsonify, json app =…
-
1
votes1
answer307
viewsReturn in python 3
I am creating a function in python3 and a question arose about the use of Return, when we call him in the code he must terminate the function immediately? In the code below this is not working, even…
-
1
votes1
answer445
viewsAccess properties of a Python file
I want to access the properties of a file using Python. I saw that it is possible to do this using the function listxattr of the OS module, but when trying to use it, it gives me an error. See my…
-
1
votes1
answer384
viewsReturn pixel of a certain color analyzed by Imagegrab
I need to identify a color in a pixel "rectangle" and return its position to save to a variable. For example, in this image, I need to detect the blue color, and when detected it returns to me the…
-
1
votes1
answer68
viewsLogic expression that controls repetition
I’m solving a Python exercise that asks the user to give a guess, on what number the program got to pc randomly. from random import randint tent = int(input('PALPITE:')) pc = randint(0,4) cont = 0…