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
votes2
answers356
viewsCounter in a dictionary value
I am a beginner in programming and am doing an exercise in which I need to count the votes of certain numbers according to the number of the player’s shirt. For example, if I type in the program 23,…
-
0
votes1
answer265
viewsHow to "reset" Python on Ubuntu 16.04 LTS
I’m having trouble in a Python library on my computer, I can’t uninstall it through Pip. I wonder if there is any way to remove the "force" library or restore Python to default configuration. Below…
pythonasked 6 years, 8 months ago Rafael de Mattos 45 -
0
votes1
answer34
viewsplaceholder for sql varchar
I’m making a program that reads the output of Arduino and sends to a SQLITE3 database. You’re making this mistake: cursor.execute("INSERT INTO reciclagem_data (personID, nome) VALUES (%s,%s)",…
-
0
votes1
answer306
viewsHow to insert caption in a linear graph with 3 vectors on the Y-axis?
x=['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'] y=[] z=[] w=[] for i in range (0,12,1): soma=np.sum(mprod[:,i]) y.append(int(soma)) for j in…
-
0
votes2
answers1669
viewsChanging the Python CSV File Delimiter
I have a difficulty in delimiting the cells of the CSV file, when I send the command to save the edited file in CSV escritor.writerow([linhas]) the default delimiter is ,, the more I need to change…
-
0
votes0
answers59
viewsForms in Django, help?
Is there any way to work with Forms in a practical way in Django? The point is that I am creating a site on my own and as I already knew Python, so I decided to use Django. "Everything" was fine,…
-
0
votes1
answer669
viewsButton Bind in Tkinter.ttk Treeview in another Class
Problem How to create a button bind class in ttk. Treeview? Sample Code When programming the main class, which defines Treeview and then create another class that defines bindings and events. It is…
-
0
votes1
answer352
viewsHTML Image Base64 in emails
I have a python API that sends emails. The problem is that I mount an HTML and tag <img> and I put a clothesline from Base64 which is the src. However 90% of email services do not accept…
-
0
votes1
answer181
viewsIn Python, how to assign stdout, stdin, and stderr to variables , using the "subprocess" module with the hidden console?
In Python, how to assign stdout, stdin, and stderr to variables , using the "subprocess" module with the hidden console? Before packaging the program in executable . exe, I can do the normal…
pythonasked 6 years, 4 months ago user110265 -
0
votes1
answer2279
viewsHow to install packages on Pip without internet access?
I’m having trouble with the python. I am providing service to a banking company, however the network is very closed, I can not download the files via pip. I can download the packages in another way…
-
0
votes4
answers11856
viewsHigher and lower value problem with while. (No list!)
Write a program that reads an integer N and then read N real numbers, separating the smallest and largest, presenting them on the screen. N = int(input("Digite N: ")) i = 0 ma = 'maior' me = 'menor'…
-
0
votes1
answer81
viewsHow to edit something saved in the Python database
I need to search a student by name or Cpf that is saved in the database and recover this same student in a form to be able to edit it and later be saving again. I am using Django as a framework. I…
-
0
votes1
answer33
viewsAdd the value 5 at the end of the list/tuple
lista_da_tupla_a=(["0", "33", "40"], ["8", "30","9"], ["7", "0", "0"]) lista_da_tupla_a = list lista_da_tupla_a[2] = "5" print(lista_da_tupla_a) Desired exit: (["0", "33","5"], ["8","30",5],…
-
0
votes1
answer187
viewshow do I detect on which side is the object if I trace a line the medium
My friends, I’m discovering computer vision. I’m programmed in python and wanted to know how I do to identify in which position the object is in relation to a line drawn in the middle of the screen.…
-
0
votes1
answer3175
viewsSelect higher value from a list // Python
I have the following problem: I need to create a program that reads a random list of positive and negative values, and returns the highest value. As a solution, I have tried using while, if and…
pythonasked 6 years, 8 months ago ViniciusCari 1 -
0
votes2
answers942
viewsHow to write an alphabetical agenda of Names, if the dictionary structure has no order?
Write a program that receives as many entries as the user wants and then create a new contact for each entry (Name, Phone, Address, Email), and finally prints, in alphabetical order, the contact…
-
0
votes1
answer99
viewsI’m doing a test with opencv and python but the code below does not return anything.... Some poedria help me see if there is any error?
import numpy as np import cv2 cap = cv2.VideoCapture('peopleCounter.avi') #Open video file while(cap.isOpened()): ret, frame = cap.read() #read a frame try: cv2.imshow('Frame',frame) frame2 = frame…
-
0
votes2
answers1021
viewsHow to run a python script that is located on another machine
I have 2 Raspberry and a windows computer that has an apache server. I want to run a script that is on the server from these 2 Raspberry. I type in the command line: sudo python3…
-
0
votes2
answers81
viewsError calling function
When I call this function: def check_bit4(input): mask = "0b010" desired = input & mask if desired > 0: return "on" else: return "off" This error appears: Traceback (most recent call last):…
-
0
votes1
answer23
viewsAdafruit_bmp in python 3
I am testing the BMP180 sensor on Raspberrypi 3 B+ and when I run the file on Raspbian gives me this error: when I run the same file from the command line it gives the values it should give, no…
-
0
votes1
answer137
viewsSyntax error in if and Elif systems
while True: ret,img=cam.read(); gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) faces=faceDetect.detectMultiScale(gray,1.3,5); for (x,y,w,h) in faces: cv2.rectangle(img,(x,y),(x+w,y+h),(0,0,255),2) id,…
-
0
votes2
answers477
viewsHow to access a private attribute in a class?
Write a program of banks you own: Uma classe Banco com os atributos - private total - public TaxaReserva - private reservaExigida E métodos - public podeFazerEmprestimo(valor) --> bool - public…
-
0
votes2
answers534
viewsPython - Select clickable
I have to display on the screen (Tkinter) a list pulled from the database (mysql) containing information about a person (name and id) and make it possible that any item on that list can be clickable…
pythonasked 6 years, 4 months ago Bruno Almeida 59 -
0
votes1
answer1539
viewsGroup data by Month/Year
import numpy as np import pandas as pd BASE_GERAL = pd.read_csv('base_prestadores.csv') indice | data_utilização| preço | quantidade_itens 1 | 2014-05-01 | 20.00 | 5 2 | 2014-05-08 | 30.00 | 6 3 |…
-
0
votes0
answers29
viewsPython: Get folder URL
How to get the path/location of the latest image stored in an x folder using Python?
-
0
votes1
answer86
viewsStoring past data - Django
My question is the following, in my application I have a profile template that has the following fields: Models py.: class Perfil(models.Model): nome = models.CharField(max_length=255, null=False)…
-
0
votes0
answers111
viewsInterface hangs while running while using from kivy.app
I’m studying image processing using Python. I interfaced with Kivy.app, but is catching when it runs the while. I am using the code below to fill an array with "0" or "1", making the image…
-
0
votes1
answer1721
viewsScreen Transition - Tkinter
Let’s say there is a screen with three buttons (Tkinter), each calling another screen when clicked. How to switch between these screens without getting that aspect of destroyed screen and a new…
-
0
votes2
answers3404
viewsTake a Tkinter entry and save to a variable
I made this initial window where I took the data, and when the client used it, after providing the data and confirming it, it closed and kept the data saved in a variable that was not tied to an DEF…
-
0
votes2
answers101
viewsCan you do it with less variables?
Constructing a program prompts the user to type positive integers, ending with 0, whose output is "yes X", without the quotation marks, if the sequence contains X positive values and forms an…
pythonasked 6 years, 7 months ago Rafael Kenji Tetsuya 1 -
0
votes1
answer134
viewsWhy are you playing the Windows error sound instead of the specified file?
import winsound winsound.PlaySound('C:/Users/Computador/Music/Action!/som1.wav', winsound.SND_ASYNC) When I run this script the file is not touched som1.wav, but rather the Windows error sound. Why?…
-
0
votes0
answers59
viewsGraphic error and simple list
import matplotlib.pyplot as plt x=[] y=[] z=[] dados=open('dados1.txt','r') for line in dados: line=line.strip() X,Y,Z=line.split() x.append(X) y.append(Y) z.append(Z) dados.close()…
-
0
votes0
answers175
viewshelp with listview Django
I need help picking up the values of an object in a list view class Compraslist(LoginRequiredMixin, ListView): model = Solicitacao template_name = 'compraslist.html' def get_context_data(self,…
-
0
votes0
answers287
viewsShow graph sum of objects - Django/Python/Sqlite
How to show a graph with the sum of objects with Django/Python/Sqlite? In this case we have 'internal boxes' (y-axis) for 'teams' (x-axis) that are rendering'internal boxes' values for each 'team'…
-
0
votes1
answer34
viewsRecursions in closures
# -*- coding: utf-8 -*- def memoize(limit, *, message = 'Limit exceded'): count = 0 def inner(func): cache = {} def wrapped(number): nonlocal count if count < limit: if number not in cache:…
-
0
votes1
answer163
viewsSending email with Python and Mysql
I am trying to send emails by Python with data from a database, but there is an error that I am not able to understand. The system makes the connection to the bank, sends the first email and when…
-
0
votes1
answer96
viewsFilter a specific element within a stripe within another list
I have a filter to find the index of a stripe inside another list (found in the author group Anderson Carlos) fila = [['vitor','5'], ['vitor', '4']] def sdb(filadb,nome,elemento): if not (filadb):…
pythonasked 6 years, 7 months ago vitor Carvalho 11 -
0
votes1
answer19
viewsE-mail with update in the bank
I am developing a code for sending emails and, if the email is sent, the system updates the bank table. Emails are being sent, but the update does not happen Follow the code I have: import MySQLdb…
-
0
votes2
answers228
viewsHow to use this script for a server list? - Python
Good afternoon, you guys. I am using this code to update some servers here in my company, via ssh: http://alissonmachado.com.br/python-e-ssh/ on line 11, we have:…
-
0
votes3
answers3361
viewsMake list with input in python
Good morning, you guys. I need help to solve a part of the college exercise. The problem is relatively simple, but I’m having difficulties. My code is this: # Subprogramas def verifica_peso(pesos):…
-
0
votes1
answer479
viewsHow to write a calendar in alphabetical order of Names using Python Ordereddict?
Nomes = [] Telefones = [] Endereços = [] Emails = [] Agenda = {"Nome": Nomes,"Telefone":Telefones,"Endereço":Endereços, "Email": Emails} entrada = "" print("Bem-vindo a nossa Agenda!!!!!") while…
-
0
votes1
answer1064
viewsTime between two dates
How do I know the amount of time in days, hours and months between two dates using Python? For example how many days, months and years there are between 22/11/213 and 25/03/2014.
-
0
votes1
answer87
viewsPython function equivalent to Crypt in PHP
I have a program in PHP that encrypts a password with the method crypt: $crypt = '$1$/E0xe3/3$yPzJElk.aVSd5JoQTopDZ/'; if($crypt == crypt($_POST['key'],$crypt)) And with that I get the following…
-
0
votes1
answer31
viewsHow to make a request and search for a string
I wonder how I give a request and look for a string, example: *www.site.com/index.php? id=' (Error SQL) (find the error) I’m just having trouble with it since it’s almost all set, so follow the…
-
0
votes0
answers118
viewsError trying to access ftp.debian.org using Python script: "Oserror: [Errno 101] Network is unreachable"
The script: import os from getpass import getpass #nao ecoa o que digita na tela! from ftplib import FTP # Variavél que determina se devemos usar o modo ativo # para FTP nonpassive = False # Nome do…
-
0
votes1
answer66
viewsPython: Serialization of json namedtuple classes
import json from collection import namedtuple class Employee: def __init__(self, name, age): self.name = name self.age = age def tojson(self): return json.dumps(self.__dict__) Hello guys, I…
-
0
votes2
answers78
viewsRequest url wikipedia by date
Hello, a great friend made me this code, I am very new in python :` from bs4 import BeautifulSoup import requests url = "https://dumps.wikimedia.org/other/pageviews/2018/2018-04/" page_html =…
-
0
votes1
answer76
viewsArchive keyboard entries in Python
I am building a code to retain any command made by the keyboard, they will be published in a topic of the ROS structure to control a mobile robot. I’m not very familiar with Python, the most I could…
-
0
votes1
answer710
viewsCreate file without knowing directory? Python
It is known that it is possible to create a new file through Python through file_create = open(r'C:\Diretório\Diretório...\FileName', 'w'). However, it is necessary to indicate where this file will…
-
0
votes1
answer174
viewsChanging how Forms.Validationerror is displayed in Django
It is possible to change the way the ValidationError is displayed? I noticed that the Django creates a tag <ul> and within it a tag <li> error. Can I change the way this is done? And if…