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
votes1
answer174
viewsMy Python code works, but I don’t understand why an int()
I did a time-calculation program on medications. According to the calculations everything is running perfectly, but I did not understand a detail, why the need to use a int() at a certain point in…
-
1
votes1
answer84
viewsCreate a python character chart
Hello, I am a beginner and I am trying to make a program that will receive a list of numbers and plot a graph using | to mark the value of the number at that position and the graph is all contoured…
-
1
votes2
answers60
viewsUnexpected outputs of a user’s serial listing code
The code I asked that asks the user the series it accompanies and has some problems: first problem: the line counter serie = str (input("Digite a sua {}a série favorita: ".format(i+1))) does not…
pythonasked 5 years, 6 months ago user141036 -
1
votes1
answer113
viewsHow can I get a program shut down by typing an empty space (' ') into python
How can I make a repeat loop while stopping when the user inserts a blank space (" ")? I tried to do so: while num != '': num = int(input("Insira um número: ")) But the variable is not an integer,…
-
1
votes2
answers25
viewsSearch for specific directories containing the entire path
Fala galera, I need help listing all directories that contain "_new", for example: /var/www/site_novo/teste already started the code to get the _new directories, it finds the same, but I need it to…
-
1
votes2
answers177
viewsPrinting of Matrices in Python
I’m starting in python and I need to solve several Python matrix exercises, but I can’t make the right impression. Understanding the Logica of this exercise I can solve the other quiet. Could…
-
1
votes1
answer68
viewsPython - value saved to database is reset
I’m doing a job for college using an Arduino and a Raspberry to make a self-contained vegetable garden. The sensors of temperature and humidity, luminosity and the hygrometer are connected to the…
-
1
votes2
answers469
viewsInsert header in Python worksheet
I need to insert an image into the header of the xlsx file that is generated by Python with a routine of capturing database data and turning it into report. I’m using this alternative method, where…
-
1
votes0
answers74
viewsHow to make a button flash Tkinter
I’m trying to make a screen where the buttons blink at certain frequencies. I couldn’t find any function that answered. Can someone help me, please? Follow the code I’ve made for now: from tkinter…
-
1
votes1
answer45
viewsI couldn’t quite understand how this code works
I saw this code to transpose the matrix but I couldn’t quite understand how it works. For me this row[i] looks more like a "marker" of an index, for example, line 1, line 2, line 3 and line 4. I…
pythonasked 4 years, 4 months ago Yasmin Teixeira 47 -
1
votes2
answers516
viewsRemove items from one list that are in another
I have two lists with values, and when I try to search an item from one to another, to see if it exists, it’s returning False even if knowing that the item exists in the searched list. proc =…
-
1
votes1
answer59
viewsTkinter, open only graphical interface
Hello, when I run a program I created using the Tkinter library in Python, it opens along with the graphical interface the console. You know how I just open the interface?
-
1
votes2
answers1434
viewsHow to make the user return the specified condition when the same type wrong?
In Python, when the user type a non-existent option, how do I ask him to type again one of the desired options? Make a program where the user can type several values and register them in a list. If…
-
1
votes1
answer418
viewsLoop in Selenium (python)
Hello, I need to display a chart in a browser (Chrome) but this chart requests authentication after a while. I learned about the Selenium tool yesterday and decided to use it to perform an…
-
1
votes1
answer294
viewsGenerate PDF in Django admin
How do I get a PDF in the Django admin? I already have the views, I can generate in the frontend with HTML all right, but how do I put a button in the admin to generate or redirect to the pdf link?…
-
1
votes0
answers53
viewsCheckbutton - I can’t leave just one option checked..... when I mark an option in step 15 marks all together.... Someone can help me...
passo = 0 msg = 'Iniciar Nova Classificação' msg_button = 'Sim' dados = ' ' dd = ' ' mm = ' ' aa = ' ' barra01 = ' ' barra02 = ' ' ckb1 = ' ' ckb2 = ' ' ckb3 = ' ' ckb4 = ' ' sim = False nao = False…
-
1
votes0
answers185
viewsHow to position an image in reportlab using pdfrw as flowable?
I’m using the reportlab to generate reports. I can define the creation process in four steps: 1) take the data via API, 2) filter the data, 3) generate the graphics with the matplotlib and 4) insert…
-
1
votes2
answers1111
viewsImport Pysimplegui in Visual Code
I have a mistake when I use Pysimplegui import PySimpleGUI as sg ModuleNotFoundError: No module named 'PySimpleGUI Pysimplegui is installed correctly on the computer so much that I use it on Spyder.…
-
1
votes1
answer120
viewsMove aquifers by extension, PYTHON
Good afternoon, I want to fine tune my skills in PY, and I’m in a small script to move files from one place to another, but I would like to do this and not be guided by the name of the file, but…
-
1
votes1
answer153
viewsNon-blocking execution with asynchronous Python functions
I want a certain flow to continue even calling a async.sleep() in the code, I have the following code import asyncio async def funcao_1(name): print("entrando no sono...") await asyncio.sleep(3)…
-
1
votes1
answer234
viewsProblem with Python Thread Print
I’m developing a python code for the philosophers' dinner... for those who don’t know, follow the link:…
pythonasked 5 years, 6 months ago Matheus F Régis 11 -
1
votes0
answers19
viewsImproving the efficiency of Camshift
I detect a previously trained object with the Haarcascade algorithm and pass the coordinates to Camshift at the beginning of the program to detect the region where the object in question is in the…
-
1
votes1
answer329
viewsHow to redesign a window with Pyqt5?
I have a CRUD made with Pyqt5 that adds a user to a database Postgresql and does a search to show registered users in a QT Listwidget. However, when adding a new user, the screen does not "reload"…
-
1
votes2
answers173
viewsReading of multiple datasets
I am trying to read Anatel’s datasets file, but it is divided by state. Is there any way I can read all the files in the folder at once? I did reading file by file and joining all in one.…
-
1
votes0
answers95
viewsImage SVM classifier does not work
Hello, I’m with a program in Python that uses the library Dlib 19.10, the classifier uses an xml file to learn the images and then I run the following code that creates a file. svm for the…
python algorithm opencv image-processing artificial-intelligenceasked 5 years, 6 months ago Marcos Paulo S. Rezende 351 -
1
votes2
answers80
viewsHow do I use the for command to solve the same problem?
In this case, the objective of the program was to make a half pyramid, as many floors as the user wanted to build, however, he wanted to use the 'for' command to accomplish this goal. quant =…
-
1
votes2
answers816
viewsIn requests, how to correctly read the ISO-8859-1 encoding?
In Python3, with beautifulsoup4 and requests, I want to extract some information from a site that has encoding 'ISO-8859-1'. I tried this strategy to show correctly the text: import requests from…
python character-encoding python-requests beautifulsoupasked 5 years, 6 months ago Reinaldo Chaves 333 -
1
votes1
answer340
viewsAdd functions in kivy
I’m a beginner in python and in gera programming, I’m doing a project for the school science fair and need help to add this function to my graphical interface (I’m using python 3.6 and I’m on…
-
1
votes2
answers2002
viewsPython binary search algorithm
Hello, I want to create a function that given a list to and a value m within this list, return the position of the value m. My idea was to start with the extreme values of the ordered list and take…
-
1
votes1
answer2449
viewscom.google.gson.Jsonsyntaxexception: java.lang.Illegalstateexception: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
Hi, I’m new here and I’d like a hand. I happen to be developing a work of distributed systems in which the client is in Java and the server in Python. For there to be communication between the two,…
-
1
votes1
answer1006
viewsPython: "list index out of range"
Issues: What makes the code snippet below? He’s making a mistake. How can I identify and correct this mistake? verificar = self.tree.column(titulos_listbox[ix], width=None) When running the code,…
-
1
votes0
answers43
viewsthread superposition bug in python
Hello, I am studying the operation of threads and I made a program where there is a function that prints the current time of 'n' in 'n' seconds, and would like to create a parallel processing where…
-
1
votes1
answer87
viewsAlgorithm for certain letter combination
I have the following problem, I want to know the combinations of certain letter in the string, example: AAbA Viraria AAbA, AAb, Ab, bA, b I arrived at the following code, but does not contemplate…
-
1
votes2
answers117
viewsWrite a program that reads a character and displays the boolean value True (true) if it is a digit between ' 0' and ' 9' if not False (false)
def cont(caracter): digito = ord(caracter) return digito == 0 or digito == 9 def main(): usuario = str(input()) print(cont(usuario)) if __name__ == '__main__': main() Where is the error in that…
-
1
votes1
answer1504
viewsCreate buttons for each item in a python list using Tkinter
I developed a software that sends consumer data to a database. I made another application to receive this data and generate a graph. My goal is to create specific button for each consumption day.…
-
1
votes1
answer48
viewsOutput values are leaving without space
I have the following problem to solve: Cryptography (Greek: kryptós, "hidden", and gráphein, "written") is the study of the principles and techniques by which information can be transformed from its…
-
1
votes1
answer37
viewsCreate loop and move to arguments of a function?
I have the following code in Python: storage.tableWidget.setColumnWidth(0, 30) storage.tableWidget.setColumnWidth(1, 140) storage.tableWidget.setColumnWidth(2, 90)…
-
1
votes1
answer67
viewsTuple FOR loop inside other tuple
I’m trying to run a loop of tuples inside another tuple. When I run the application it just returns me the last tuple. minha_tupla = (('willian','123','25.26'),('carla','654','45.58')) titulos =…
pythonasked 4 years, 2 months ago Willian Silva 23 -
1
votes2
answers508
viewsPhyton wait pause
I want to automate a task, as the software has no api that allows this, I will control the mouse of the OS and click using Phyton. I intend to create validations with images to ensure that I am on…
pythonasked 5 years, 5 months ago Tiago Oliveira de Freitas 1,798 -
1
votes2
answers257
viewsHow to recover a specific chunk of text
I have a configuration file and need to get a specific chunk of a configuration, which would be the best way to do this? In the example below I need to take the section that starts in "config system…
-
1
votes3
answers227
viewsLambda python function
I’m trying to do a python lambda function that finds the largest element in a list that has length N. If you make the following code, you’d be right? maior = reduce((lambda x,y: x if (x > y) eles…
-
1
votes1
answer57
viewsPydantic - Convert "str" to "bool"
Good afternoon, I would like to convert data directly by pydantic. I receive in "str" data "no", "yes", "na", no" ... which needs to be converted to "bool". from pydantic import BaseModel class…
pythonasked 4 years, 2 months ago Eliton Oliveira 5 -
1
votes0
answers26
viewsTimestamp in Django (Reference)
I need this: strtotime('+10 days'); = PHP in Django I tried: import time struct_time = time.strptime("+10 days") print "returned tuple: %s " % struct_time Well, in all the documentation it doesn’t…
-
1
votes1
answer159
viewsPython - Pyqt5 - how to insert a Qgridlayout into a Qmainwindow?
Good afternoon, everyone. I got a problem. I’m using Qmainwindow to create a screen where I insert a Qmenubar successfully, but then I’ll try to insert a Qgridlayout and it doesn’t work. No error…
pythonasked 5 years, 5 months ago Cleber Nandi 137 -
1
votes3
answers193
viewsTake values less than or equal to 500 from the list - Python
Code: acid_vit_lista = [100,500, 200, 230, 400, 500, 600, 700, 900, 2000, 1100] acid_vit_dig = int(input('\nNumero de acidentes de transito: ')) res_acid = (acid_vit_lista[num_dig])# num_dig foi da…
-
1
votes1
answer177
viewsRepeat an algorithm if the answer is wrong in guessing game without losing the drawn number
I made an algorithm in Python with the proposal to guess a number as the user type, ie the guessing game. But I would like to make a condition that makes him type again, in case he does not choose…
-
1
votes1
answer123
viewsDisplaying only integer values on X-axis in matplotlib chart
I would like to show X-axis only integer values of K: k in range(20) import matplotlib.pyplot as plt %matplotlib inline X = [k for k in range(20)] y = rmse_val plt.plot(X,y,color='green' ,…
-
1
votes1
answer420
viewsqueries in Django’s views and template
I have two tables (Client) and (Animal), the animal table is related through a Foreign key with the Client table, currently I can register only client, register client and animal together, in the…
-
1
votes4
answers361
viewsHow to count occurrence of strings within a dictionary made up of lists in Python?
I have a satisfaction research dictionary that the evaluator can evaluate up to 6 products. The program stores the evaluator, the refrigerant and the note for the refrigerant. And I have to show the…
-
1
votes1
answer84
viewsAttribute Error: scipy has no attribute 'Stats'
I am getting this error while trying to import the Pyfolio library, I tried to import first: import scipy.stats or from scipy import stats and I was not successful. I can import scipy but when…