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
answer50
viewsI’m having trouble putting two matrices together
def matrizsomada(a, b): num_elementos_a = len(a) num_elementos_b = len(b) x = [] for i in range(num_elementos_a or num_elementos_b): x.append([a[i],b[i]]) return x a = [1,2,3] b =…
pythonasked 4 years, 8 months ago Caio G Sa Silva 11 -
0
votes1
answer624
viewsPerform date filtering within a column using Python
good afternoon. I need to do an Excel file filtering, this filtering consists of taking a particular column and performing its filter. I’m a beginner here and I don’t know if I’m making the most…
-
0
votes3
answers1736
viewsFind word in python txt file
I have a program called anagrams.py and its function is to show the permutations of a word typed by the user if it is in the file words.txt. This is the complete code: """ Anagrams by WhoisBsa """…
-
0
votes1
answer340
viewsHello, in Tkinter how to take the value of the sum generated by numbers and compare with the user input?
from tkinter import * from random import randrange, uniform window = Tk() window.title("Welcome to LikeGeeks app") window.geometry('800x600') lbl1 = Label(window, text="00", font=("Arial Bold", 50))…
-
0
votes1
answer201
viewsFill in field with "00-00-0000" when empty
I am making a recording in the database (Postgresql) with Python, I use a base on .txt. Problem: At the base have some records are blank, and is giving error at the time of recording, occurs in the…
-
0
votes3
answers238
viewsUpdate label every time you click a button
I’m using the Tkinter library for the program interface, so on the screen I would have a label that starts with your text represented by a variable of value '10', so at the click of a button, I…
-
0
votes1
answer530
viewsAnaconda for Pycharm on Linux
People I am not able to access, the anaconda in pycharm, first I tried to access two libraries and appeared this error. Libraries: import pandas as pd import numpy as np error: Traceback (most…
-
0
votes1
answer51
viewsHow to delete a character in Python
I’m starting a study with data analysis, but I still don’t know how to delete characters import re import panda as pd df.rename (columns = ("nome_motorista***************": "nome_motorista")) that…
-
0
votes2
answers80
viewsWhere do I add the ". py" calculations to the HTML page?
Speak, people! Blz? I’m starting out in the area and I’m having a lot of questions. I set up a basic HTML test page and wanted to insert a python code I created (test calculation). Where and how I…
-
0
votes1
answer405
viewsProblem when displaying text with cv2.QT_FONT_BOLD source using Opencv in Python
I’m having trouble showing a specific text in an image, I believe the problem is in the source used (cv2.QT_FONT_BOLD), because when I change the source to another as cv2.FONT_HERSHEY_COMPLEX_SMALL,…
-
0
votes1
answer221
viewsRead csv with multiple lines in python
Hello, I would like suggestions on how to read a csv file, I am maintaining a script, but it only returns the first line. I did some tests with some templates I found on the internet again only the…
pythonasked 5 years, 8 months ago Lorena Jesus 15 -
0
votes2
answers370
viewsHow to verify which numbers of a matrix are primes?
My code so far def numerosPrimos(matrix): lista_primos = [] for i in range(len(matrix)): for a in range(len(matrix[i])): if matrix[i][a] > 1: for c in range(2,matrix[i][a]): if matrix[i][a] % c…
pythonasked 5 years, 8 months ago Paulo Smith 3 -
0
votes0
answers4459
views'. ' is not recognized as an internal or external command, a operable program or a batch file
When I try to use the remote ./configure in windows cmd to install freetds I get the message '.' is not recognised as an internal command or external, a operable program or a batch file.…
-
0
votes2
answers43
viewsRemove gray squares from my Tkinter program (Python)
I would like to remove these gray squares from my program. from tkinter import * import datetime import time import pygame, sys, random pygame.init() root = Tk() root.title("SISTEMA DE VENDAS")…
-
0
votes1
answer62
viewsFlask Restful - get sub element with reqparse
I’m setting up an API in Flask and the request is as follows: Request: http://127.0.0.1:5000/integra json = {"recev": {"doc":"123456"} } I’m trying to get the key value "doc", but to no avail: from…
-
0
votes3
answers78
viewsInsert a list into a database made with Django
Hello, I want to insert a list of names in a database I created with Django, but I’m not getting it. Is there a method to enter all names at once? (NOTE. I have already performed the makemigrations…
-
0
votes1
answer182
viewsPlot function of igraph - (python)
I tried to use the igraph library for python in order to plot a graph, I used the very example of the documentation, but it didn’t work. Code used: import igraph from igraph import plot g =…
-
0
votes1
answer34
viewsHow to create a function that inserts at the bottom of the list (PYTHON ) using the signature : def inserts Fim(self, item)
class Noh: def __init__(self, campo): self.campo = campo self.prox = None def getCampo(self): return self.campo def getProx(self): return self.prox def setCampo(self, nc): self.campo = nc def…
pythonasked 5 years, 8 months ago Matheus Velasques 11 -
0
votes1
answer610
viewsHow to collect snippets of a text with the Pageobject object from the Pypdf2 library?
Going remove a section of text of a PDF with the library PyPDF2 in Python. Precise find the word "Lc" inside the PDF and extract it: the word "Lc", which means leasing, comes accompanied by a number…
-
0
votes2
answers61
viewsGet the number of files contained in a directory
I’m using the following script: import os ler = os.system('ls livros | wc -l') print(ler) The goal was the variable ler receive the number of existing files inside a directory but it always gets the…
-
0
votes3
answers77
views*Python- why is my code giving me information I didn’t ask for?
should only show me the value of the fuel I requested, but it shows me the value of both gasoline and alcohol, no matter if I type D or A: tipo_comb = input('Digite [G} para gasolina \nE [A] para…
-
0
votes0
answers130
viewsfloat64 in the Pandas
I have a table 'f0219' with a column 'Value'. Originally, value is like Object. I use the following command to convert it to float. f0219['Valor'] = pd.to_numeric(f0219['Valor'], errors='coerce')…
-
0
votes3
answers2069
viewsCalculate the arithmetic mean of the integers between 15 (inclusive) and 100 (inclusive)
I need to calculate the arithmetic average of the integers between 15 (inclusive) and 100 (inclusive). I made this code: x=0 for i in range(15,101): x=x+i print('%d / %d = %5.1f' % (x,i,x/i)) If the…
-
0
votes2
answers470
viewsread the elements of an input matrix
I have a code that represents a checkerboard (8x8 matrix): print(f'ATENÇÃO: ') print(f'Insira 0 nas posições vazias do tabuleiro;') print(f'Insira 1 nas posições das peças pretas e 11 para as damas…
-
0
votes1
answer54
viewsFunction to increment the file name - python(opencv)
i have this code that saves me a video every time I run the program with the name video0. out = cv2.VideoWriter(video0.avi', fourcc, fps, (int(width), int(height))) I wanted him now every time I ran…
-
0
votes1
answer189
viewsPython error saying that the file does not exist, but it does exist
Code: import csv import random dataset = [] with open('data.csv') as _file: data = csv.reader(_file,delimiter=',') for line in data: line = [float(elemento) for elemento in line]…
pythonasked 4 years, 8 months ago Bruno Luiz Bender 31 -
0
votes1
answer220
viewsSwitching pages in an html table with beautifulsoup
I’m collecting the data on this one website, using requests and beautifulsoup. I was able to collect all the data from page 1, but I cannot change the page. Python code variaveis = [] df_list = []…
-
0
votes1
answer1417
viewsMove python files to another folder in another directory
Friends, I need to move a file to another folder in another directory after renaming it in Python. I’m a beginner in Python and may lack a little vision to solve the problem. I tried to move when…
pythonasked 5 years, 8 months ago Diego bronstein lopes 3 -
0
votes1
answer97
viewsSelenium Staleelementreferenceexception Problems with Python
I am new here in the forum,I hope you can help me, I am creating an application with Selenium using python to collect documents on a specific site. documents are uploaded to download via javascript…
-
0
votes1
answer320
viewsChange distance on x-axis - Matplotlib
I’m mounting a chart using the Python matplotlib library but the result is not good! The names of the x angle are not visible. Follow picture Code: #-*- coding: utf-8 -*- #Meu Décimo oitavo Programa…
-
0
votes2
answers719
viewspython: Attributeerror: 'int' Object has no attribute 'Count'
I have a code that is returning me the following error AttributeError: 'int' object has no attribute 'count'... I have a list of multiple numbers, and I need to know how many repeat numbers from 1…
pythonasked 5 years, 8 months ago Claudinei Miller 29 -
0
votes1
answer171
viewsHow to run a virtual python Environment on the linux crontab?
created a virtual Environment: python -m venv test pip install -r requirement.txt And I created a scrip C:\fnord\Documents\Scripts_python\test\Scripts\test.py So, how should I proceed to create…
-
0
votes1
answer148
viewsHow to share a dictionary between scripts
I have a central dictionary that gets all jsons files from my working directory: def loaddata(): with os.scandir('Jsons/') as it: for entry in it: if entry.is_file() and…
-
0
votes1
answer87
viewsHandling characters not saved in variables with F'strings in Python 3
To manipulate unsaved characters in variables with F'strings I do this: print(f'{"String":^20}') I wonder if this is right, or would it be a scam for the fact that I have to define the string inside…
-
0
votes0
answers249
viewsPython matrix sum 2x2
m = [] for l in range(0, 2): m.append([]) for c in range (0, 2): valores = int(input("Digite valores: ")) m[l].append(valores) print("-"*30) print(m) print("-"*30) for l in range(0, 2): print("|",…
-
0
votes2
answers1261
viewsPython URI Online Judge (1021): what’s wrong with my code?
Enunciation: Read a floating point value to two decimal places. This value represents a monetary value. Next, calculate the smallest number of possible banknotes and coins into which the value can…
-
0
votes3
answers138
viewsThe why of using break
I wanted to know why the use of break in code(I realized that without break, the code is flawed): lista = list() pos = 0 for c in range(0, 5): n = int(input('Digite um valor: ')) if c == 0 or n >…
-
0
votes2
answers78
views -
0
votes1
answer1065
viewssort graphing and fix value in python
I’m trying to make a graph of the variation of the prices of the Itau stock however the result is with the values of disordered shares insira o código aqui import matplotlib.pyplot as plt dados =…
-
0
votes1
answer256
viewsCreating decency function
Hello, I’m new in Python and I’m trying to create a function that returns the decendio something like in the figure: this is the conditional formula in excel:…
pythonasked 5 years, 7 months ago aluno estudent 1 -
0
votes1
answer342
viewsReturn word media in a dictionary from another function
I need a function that receives the result of a word counting function and based on these values, this function calculates the average of how many times a word appears in the text, stores that…
-
0
votes0
answers92
viewsLoop For with Zip(), how to select the amount of records?
I have this code that works normally def pdd(number, entrada): for i, j, k, l, m in zip(entrada[:-1], entrada[1:], entrada[2:], entrada[3:], entrada[4:]): if number in i: print([j, k, l, m])…
-
0
votes0
answers85
viewsPython: Sslerror, bad Handshake, Unexpected EOF em get request
I am trying to get a request on a specific site, but am having problems with the error listed below. My code: import requests url =…
-
0
votes1
answer99
viewsReturn of a for in a python list
I would like to use the return of a for that list files from a directory to use in a Mysql command, but I can’t get all the files. thanks in advance for the help! #Lista os arquivos do diretorio…
-
0
votes1
answer145
viewsChoices values are being stored like this ['Dog', 'Cat', 'Birds']
I have a system that will have the option of choosing 1 or multiple options in the same field. Bad problem is that I need my field inside the model to be charfield and in Forms to be…
-
0
votes2
answers806
viewsHow to use cv2.imread() with an image type object instead of "image path"?
I wonder if there’s any way to do something like this: import cv2, pyautogui screenshot = pyautogui.screenshot() cv2.imread(screenshot, 0) Instead: import cv2, pyautogui screenshot =…
-
0
votes1
answer148
viewsWhat does "[:, : -1]" mean after iloc in Python?
I have the following line of code: X = data.iloc[:, :-1].values I can’t understand why : before the -1.
-
0
votes1
answer191
viewsRequest Reverse Post Office API
I am trying to use the Post API to perform the reverse posting method. I am using the following link to access this method: http://webservicescol.correios.com.br/ScolWeb/WebServiceScol?wsdl Whenever…
-
0
votes2
answers60
viewsHow to create variables dynamically (Speech_recognition)
I need to transcribe a 21 minute audio using speech_recognition and recognize_google the problem is that the api does not allow any audio size, I do not know exactly which but it is greater than 30…
-
0
votes0
answers347
viewsHow to create a function to pass a JSON in the Django Rest framework?
I am studying drf and would like to create a function that would receive a list in JSON format and do an update by serializer. To illustrate better follows as I am thinking. example_serializer.py…