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
-
0
votes1
answer85
viewsHow to return a number as if it were a date?
Receive the date in the dd/mm/yyyy text format and return the date in the yyyymmdd number format (example: take "05/10/1983" and return 19831005). But it presented an error in the syntax. def…
-
0
votes1
answer129
viewsPython UDP Broadcast
In python 3.7, when I send a broadcast (via UDP), you need to specify the port. Is there any way I don’t need to do this? Example: socket.sendto(b, ('<broadcast>', 15000)); #Nesse eu…
-
0
votes1
answer1142
viewsHow to fix this Json error
I’m collecting data from an Api that retrieves the information in a Json dictionary to play on an appweb so the server gives me this error how can I fix it? Mistake you’re making: Traceback (most…
-
0
votes1
answer102
viewsIs that a Python 3.6 bug?
The code below is a demonstration of what I’m trying to do: I have a vector (todos) in which elements are added. The second vector (alguns) also receives new elements, and I need to know if the…
-
0
votes0
answers42
viewsHow to Move Servo Motor Sg90
Like I would do where the print("RED"), print("GREEN") and print("BLUE") to move a servo motor at 180°, what happens is that the engine does not move, (I’m using Raspberry pi 3 b+). if r >= 50…
-
0
votes2
answers462
viewsAssignment of Boolean within a ternary operator
I would like to know why this syntax is invalid and how to do the equivalent with a ternary operator seventh_state = False state_machine_var = 1 for x in range(0, 10): state_machine_var += 1…
-
0
votes0
answers329
viewsModulenotfounderror: No module named 'requests_html'
I’m trying to use the module requests-html however in Mac OS 10.14, it presents this error both when trying to install with Pip and with easy_install it presents the error saying that this module…
-
0
votes2
answers199
viewsI’m trying to use an asynchronous function in python-3, but it’s giving error
Error: Warning (from warnings module): File "C:\Users\tiago.pereira\Desktop\python\kivy\kivy_teste.py", line 43 pythoncom.PumpMessages() RuntimeWarning: coroutine 'Keyboard' was never awaited…
-
0
votes1
answer644
viewsHow to change data using Forms. Form on Django
Good afternoon guys, I made all my form using (Forms.Form) only that I am not able to create a function to edit the form data. Below is my code: (I am using the same registration form template)…
-
0
votes2
answers142
viewsI’m having repeat problems in python
while True: nome = str(input('nome do aluno: ')) if nome == 'sair': break elif nome in notas: print(f'\n{nome}',nome.upper()) n1 = float(input('Nota do…
-
0
votes1
answer37
viewsMy script looking for a string in another string is taking too long
My script loads the command1(file1) and saves the first column of all rows in an array, later it will search for each substring of that array in a 2(from command2) file. The problem is that file 1…
-
0
votes1
answer83
viewsBasic error in python
I created this script, but is giving this following error: print('Choices\n1-Option 1\n2-Option 2\n3-Option 3') if choose =='1': print('The account is 5+5') elif choose =='2': print('The account is…
-
0
votes1
answer176
viewsProblem activating the Virutal environment with pipenv
When I opened the powershell inside Visual Studio Code, first, there was an error that the script execution had been disabled, I went to the windows powershell and changed the execution policy.…
-
0
votes1
answer830
viewsPython: Tkinter + SQLITE. Save records to database and clear field
I am studying, on my own Sqlite, I already bought some courses, but I need a help. Objective: I would like to save the user typed fields in the database and then clear the same fields to allow new…
-
0
votes1
answer2656
views -
0
votes1
answer260
viewsFalse return when comparing two python identical strings
I’m trying to compare two strings, one comes from the database as an array, the other is written by hand: string = str(profile[1]) #Carlos Gimenes print(string == str('Carlos Gimenes')) #Retorna…
-
0
votes1
answer198
viewsMaintaining the relationship between vector elements after a Python sorting
I have two vectors X and Y, I want to plot an XY graph with them, that is, the element at position X[0] corresponds to element Y[0] and element X[1] to Y[1] and so on. But my vector X is disordered,…
-
0
votes2
answers142
viewsManipulation of items during iteration
In Python it is somewhat common to go through items of a everlasting handling or verifying the existence of a particular item, or whatever the operation is. I am reading the Python documentation…
-
0
votes1
answer84
viewsSet attribute of another Python class
I am studying python and would like to understand how I can define an attribute of a class based on attributes of another class. I’ll go to the example to be clearer, it’s just an example of what I…
-
0
votes1
answer53
viewsDates in python
How can I get multiple different dates in the same run as my script? I got my script done this way: from datetime import datetime, timedelta Time = '{:%H:%M:%S}'.format(datetime.now() +…
-
0
votes1
answer630
viewsPython - Json : Keyerror
I’m making the call in a Mailchimp API in which I list the fields to insert into my DB. In the JSON provided by the documentation, the following fields appear: { "automations": [ { "id":…
-
0
votes0
answers54
viewslist index out of range, reading data and saving a variable
Hello! I need to read a data that is in a list at position 13 and is repeated every 15 values. Using the following code I receive error message: for i in range(0,len(dado),15): lat = texto.pop(13+i)…
-
0
votes1
answer51
viewsopenCV - Differentiate RGB and P&B photos into a directory
Hello, Good morning. It has a directory (linux) with thousands of photos, and I need to separate color from black and white. I created the algorithm to scan all the files and move them to a specific…
-
0
votes0
answers20
viewsdoubt in kivy archive K
I’m having a doubt on a tag in Kv file that I can’t understand its function <TableData>: rgrid: rgrid bar_width: 25 scroll_type: ['bars'] bar_color: [0.2, 0.7, 0.9, 1] bar_inactive_color:…
-
0
votes0
answers57
viewsRun a python script in Redhat 7.4
Good morning fellows I made a script to integrate Telegram to Zabbix and forward the incidents. The problem, the script only runs at the prompt using #python Telegram.py However when I run…
pythonasked 6 years ago Alessandro Teixeira 1 -
0
votes0
answers17
viewsPython problem in postgres on MAC
Guys, I’m testing Trigger functions with python on Postgres and I’m having problems when I go to test on my Mac. Follow the function: create function sendchange() returns trigger as $$ import…
-
0
votes0
answers47
viewsSave query output to JSON and count results
I have a JSON with the following structure (I cannot change the JSON structure because it is used by another script): [ { "Latitude":"-22.1156051", "Status":"1", "Id":1, "Longitude":"-43.2100901",…
-
0
votes1
answer126
viewskivy recycleview with line with multiple items
How to make a recycleview with multiple items in a row? The examples I studied using Recyclegridlayout the columns become independent and so does not look good. An example of how I wanted to do:…
-
0
votes1
answer531
viewsHow to make this program repeat itself?
Which command is useful for running the program from the beginning to the end?? f=float(input("Digite 0 para retânglo, 1 para triângulo:")) if f==0: a=float(input("valor da altura:"))…
-
0
votes1
answer49
viewsHow to transfer an HTML table into a Data Frame
I’m trying to integrate a python script with an HTML table How can I do that follows my schedule. <table data-spy="scroll" class = "table-responsive-sm" id="table-prem" > <thead> <tr…
-
0
votes1
answer1162
viewsPython module import problem
I am with a proble, use Python 3.6.7 I am making a Flask application with the following structure: /app /arquivospy consultaMercados.py definirMercados.py interfaceBD.py main.py outros arquivos py…
pythonasked 6 years ago Stefano Emmanuel 7 -
0
votes0
answers71
viewswhile with conditions or
I have the following code: while (operacoes is not '+') or (operacoes is not '-') or (operacoes is not '*') or (operacoes is not '/'): operacoes = str(input('Escolha uma das operações matemáticas a…
-
0
votes1
answer2830
viewsConverting Bases to Python
The code below takes a decimal number and converts to bases from 2 to 9 def converte(numDecimal, base): if numDecimal != 0: numConvertido = "" while numDecimal > 0: resto = numDecimal % base…
-
0
votes0
answers63
viewsError : Pending Templatenotfound
I want to create a basic application, but I’m not able to render Project structure ├── Project │ ├── Controllers │ ├── __init__.py │ ├── __init__.pyc │ ├── Models │ │ └── Conexao │ ├── templates │ │…
-
0
votes2
answers125
viewsDoubts about the Use of Beautifulsoup
My code below is to take the genre of the movies of the site IMDB, however I’m not knowing to take the tag in specific genres of the site, because sometimes instead of it catch the genre he takes…
-
0
votes1
answer372
viewsSHA256 hash generation of compressed.zip files
I would like to generate a hash with SHA256 of a set of files. For this I compressed all in format .zip and I am using the following code(Python): from hashlib import sha256 myFile =…
-
0
votes0
answers110
viewsHow to save and finish python code?
I’m using a camera to capture video, and save the video. I’m trying to save and finish the code with a command in the IDLE(python) but I’m not getting it. Actualement to finish and save the program…
-
0
votes2
answers382
viewsRegular expression that finds patterns in which some terms can change?
I need to find a pattern within a text. Example: PROJETO Nº 1.100 DE 28 DE DEZEMBRO DE 2018. Within this pattern, the word PROJETOS may also be PROTOCOLOS and the character º can be o. Thus, the…
-
0
votes0
answers278
viewsreading/manipulation of python images
I use Windows 8.1 ( 64 bits ); Python 3.7, Spyder 3 and Scikit-Image Library, all included in the Anaconda package. Here’s the super simple code: from skimage import io img =…
-
0
votes1
answer252
viewsDetect color in an area with Pyautogui
I wonder if there is any way to detect a certain color in a predefined area with Pyautogui using Python. Something like pixelMatchesColor, but to detect color in an area not at a point.…
-
0
votes5
answers158
viewsPython - Function that copies content from one list to another list
I need a function (copie_list, transcribed below) that takes two lists, dest and orig, and copies the content of orig to dest, see example below: >>> a = [8, 9] >>> b = [1, 2, 3,…
-
0
votes1
answer232
viewsAdd Entries to a Multidimensional List using input in Python
there Python master, I have the following code: veiculos = [['Fusca', 'Escort', 'BMW'],['1600W', 'XR3', '325i']] print(veiculos) print(veiculos[0][0],veiculos[1][0])…
-
0
votes1
answer329
viewsChange word in jars according to dictionary
There is an exercise that consists of typing an N number and then typing in N lines a word and a quality. After this I must type a sentence. If in this sentence there is a word that I had typed…
-
0
votes1
answer55
viewsmy python file is not being written
I have this part of code: with open('HTMLComposition.js', 'a', encoding="utf8") as JSIncludeFile: JSIncludeFile.write(Code = (""" //JavaFile DivsForComposition = """, divsForHTMLComposition, """ for…
pythonasked 5 years, 3 months ago Albuquerquess 1 -
0
votes1
answer262
viewsWhat is the question line += 1 in this code?
Can someone explain to me the function of the line questao +=1? I’m a beginner and I’m trying to understand the logic behind the code and not just make it work. pontos = 0 questao = 1 while questao…
pythonasked 5 years, 3 months ago Daniel Coelho 1 -
0
votes1
answer143
viewsWrong answer and I don’t know why in Python
I have a doubt in the following question: Ages and heights of K students have been noted. Make a Program that determine how many students over 13 are below the height of average height of all…
pythonasked 5 years, 12 months ago Vinícius Lucena 36 -
0
votes2
answers79
viewsRead file without displaying space
Guys, I’d like to know how to print a txt file without displaying line breaks and spaces. For example, the text in the.txt file is this: The rat chewed his clothes Of the King of Rome I’d like to…
pythonasked 5 years, 3 months ago Heitor Henrique 5 -
0
votes2
answers112
viewsSeparate a string into blocks according to similarity
I have the following challenge proposed: input: "aaaaabbbbccccccaaaaa" output : "5a4b6c7a" And I made the following code to solve it: def conta_numero_letras(string): armazena = '' for letra in…
pythonasked 5 years, 3 months ago Diovana Valim 203 -
0
votes1
answer1716
viewsSearch all different elements of a column (pandas)
I developed this part with the functions learned in the classroom #importando pandas import pandas as pd #criando o dataframe base = pd.read_csv('C:\\Users\\lsilv\\Desktop\\acessos.csv') #renomeei…
-
0
votes1
answer312
viewsfetch api GET method with Django
Talk guys good day, I’m with a form that the user enters Cpf and ra and receives its id_registration, I’m trying to do this with ajax, but always returns 500 Internal Server Error, follows my line…