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
answer41
viewshow to create a lock in the code
if the wrong note is typed twice and it goes to the second note a = int(input('digite a primeira nota: \n')) if a > 10: a = int(input('Nota invalida digite novamente: \n')) b = int(input('digite…
pythonasked 3 years, 8 months ago Bruno kanso 11 -
0
votes2
answers419
viewsPython project and Tkinter menu
Well my little project with python and the Tkinter library , I’m trying to make a registration system but I’m a little new in this part of object orientation in python, and I think this is the part…
-
0
votes2
answers179
viewsSkip line in XML with Python
Hello! I am creating a program in Python where the output of the program will be an XML script in the ABAP language (for a SAP specific transport), but when I export the output to XML it does not…
-
0
votes2
answers405
viewsIgnoring a line from a txt file
I read a file . txt where I want to separate each word by comma, ie when finding a space before the word and after. But I also need to ignore the entire txt line where the ##character is. Below…
-
0
votes0
answers177
viewsBlur in a specific area with Opencv
I am trying to blur a face found in a video using Opencv but am having the following error: cv2.error: Opencv(4.1.0) /io/opencv/modules/imgproc/src/filter.simd.hpp:220: error: (-215:Assertion…
-
0
votes0
answers56
viewsVLOOKUP IN PYTHON USING MERGE
I have a dataframe called df with a column of countries in several languages and another dataframe called ct that I have a column with countries in several languages and another column with the same…
-
0
votes1
answer509
viewsHow to Serialize more data from more than one table in Django Rest-framework
Speak People! I am the following problem: I have a buy-and-sell schedule: class SalesOrBuy(models.Model): client = models.ForeignKey(Client, null=True, on_delete=models.CASCADE) mode =…
-
0
votes1
answer21
viewsSkipar an optional argument among several in Python
In the following code: def FuncEx(hashTag, lang="pt-br", pages=3): sel.get(f"A hashtag {hashTag}, na linguagem {lang}, no total de {pages} páginas.") How could I do if I wanted to pass only the…
-
0
votes0
answers26
viewsHow to use an html page as input in opencv python?
I need to overlay an html page on my camera using Opencv (Python), but I don’t know how I could do that. I managed to do something similar to that code: import cv2 cap =…
-
0
votes0
answers45
viewsHow is the function returning the name?
As the function fala_oi is managing to return the nome? def mestre(funcao, *args, **kwargs): return funcao(*args, **kwargs) def fala_oi(nome): return f'Oi {nome}' executando = mestre(fala_oi,…
-
0
votes1
answer103
viewsHelp with simple program of function and sum
Gentlemen, I’m trying to solve the following exercise: Exercise 2: Write a Python function, called soma_n, that takes an integer number, n, and computes the sum 1 + 2 + ... + n, if n > 0, or -1 +…
-
0
votes0
answers24
viewsHow do I remove some data from a list
I am working on a project that I need to remove data from a Python list, but when I put the index I want, it comes out only the first letter, or the first character.…
pythonasked 3 years, 8 months ago Gabriel Camargo 1 -
0
votes1
answer196
viewsHow to place an AUTOINCREMENT ID?
I’m making a login table, where you log in, add your service data and add a company to which you work. But I’m having trouble adding the user id. I want that so q the person make his registration,…
-
0
votes0
answers259
viewsMatplotlib.pyplot with Django
I’m trying to insert a graph through the matlib.pyplot library, but I can only upload it externally by inserting it into Jango. I want to insert it as a loaded image, that when receiving data from…
-
0
votes1
answer183
viewsHow to sort bar chart from larger to smaller value
I have made the following chart. I would like to sort from the highest to the lowest value. fig, ax = plt.subplots(figsize=(8,5)) sns.countplot(olist_geolocation['geolocation_state'])…
-
0
votes4
answers84
viewsError when using index to pick up a specific index
I would like to take the position from where the highest entered value is within the list. I am trying with the index but am not getting. for c in range(0, 5): num.append(int(input('Digite 5…
pythonasked 3 years, 8 months ago Gabriel da Silva Santos 64 -
0
votes1
answer44
viewsI can’t understand that kind of import
I’m beginner in Python and I came across something I didn’t understand: import pygame from pygame.sprite import Sprite class Bullet(Sprite): def __init__(self,ai_settings,screen,ship): My question…
-
0
votes0
answers72
viewsSpeech recognition error in python AI
Hello I have an error that it displays the message but not what I said main.py Ouvindo.... Você disse {'alternative': [{'transcript': 'você disse', 'confidence': 0.88387161}, {'transcript': 'você…
-
0
votes1
answer197
viewshow to make a password generator without using multiple loops?
As you can see the program below "generates" several strings of unique characters. The intention here is not to create a specific algorithm for this, it is just an example. The case study is about…
-
0
votes1
answer142
viewsCommunicate Checkbox with Python
I have a "checkbox" button with a JS event, the JS events are running normally, but I would like my JS code to run a file. py when checkbox is checked. How can I do this? this is the html code…
-
0
votes0
answers31
viewsTypeerror: an integer is required
Good Afternoon. I am programming a script with the socket library, struct and ctypes, to sniffing the packages on the network, but I’m having trouble in the section that passes the first 20 bytes of…
-
0
votes1
answer65
viewsClassification of grammar in nltk
I am using the lib Natural Language Tool Kit to treat some texts and in this lib has the feature Rslpstemmer() removes almost the whole word and leaves the radical. But the words Perfect homonyms…
-
0
votes0
answers19
viewsHow does the self parameter work in the class?
How self works in class? class Cachorro: def comer(self): print('Cachorro está comendo.') dog = Cachorro() dog.comer()
-
0
votes1
answer43
viewsDjango - add user as team member in view
How to allow a user to register to already become a team member through their own view in Django? I tried it this way, but nothing happened. py views.: def cadastro(request): form =…
-
0
votes1
answer202
viewsUse selected path in listdir
I’m starting to learn python (it’s actually my first language kk). I work with photos and I have a project to develop a photo renaming tool, but I’m having a hard time integrating some parts of the…
-
0
votes0
answers63
viewsUnderstanding Code for Study Purposes (OBI - Python)
I would like to understand an algorithm about OBI 2017 - Cutting Paper link: https://olimpiada.ic.unicamp.br/pratique/pu/2017/f2/papel/ cannot understand why at the time of making the paper cuts he…
-
0
votes2
answers235
viewsHow to Update to a DB Sqlite3 with POO?
I have a product registration program with everything working only I lack the update, I can update edit the data in the table and in the bank but it is not working right. It edits all the data and…
-
0
votes2
answers69
viewsHow to replace file extensions?
I am learning python in Oursera, and came across the following exercise. My question refers to how to change string extensions .hpp to .h inside the list comprehension: filenames = ["program.c",…
-
0
votes1
answer315
viewsHow do I do a simple math calculation on Tkinter?
I’m trying to make a simple mathematical calculation in Python but when I try to use my code it doesn’t work My code : import tkinter as tk from math import * win = tk.Tk() win.title("Calculadora de…
-
0
votes1
answer729
viewsError: No module named 'email.utils'; 'email' is not a package
Hello, any script I run, returns me the following error. /bin/python3 "/home/Hofferman/Scripts Python/Untitled-1.py" 1 ↵ Traceback (most recent call last): File "/home/Hofferman/Scripts…
-
0
votes2
answers120
viewsCreate a variable inside an xpath
I’m trying to create an automation in python - (web scraping) that has a loop in which xpath changes every time you click on the desired location, so I realized that xpath only changes one digit:…
-
0
votes1
answer569
viewsError reading a column of a file . xlsx using Python pandas library
I need to create a Python list from a column of an Excel file using the pandas library. I have already installed all library components and the files are in the same directory. from pandas import…
-
0
votes0
answers87
viewsPerform telnet using proxy with python
I’m trying to accomplish a telnet at the door SSH 22, using the pysocks, but it seems that the SOCKS not connecting, but if I use the program Open Text Socks Client Dasboard it connects, but I need…
-
0
votes1
answer43
viewsSelect only returns result in terminal
I’m having trouble understanding why the code below only returns result when executed in the terminal. I intend to return hash of the last id entered in the database connection =…
-
0
votes0
answers456
viewsDownload pdf with python Selenium and Chrome
I have a script that enters a site by Selenium, click on a button that generates the pdf on the site, through the code below I made this pdf be downloaded automatically, but stopped working a few…
-
0
votes0
answers70
viewsIf running under false condition
Hello, I started today with python. I’m making an algorithm that returns the root of a polynomial (2x -4) by the bisection method: The methods I will use in the main function (biseccon). Since [a.…
-
0
votes1
answer78
viewsI want to know how to show, for the user, Yes or No instead of True or False, respectively
Below is an example of what I’m trying to do: lm = input ('Digite uma letra ') print ('essa é uma letra minúscula? {}' .format(lm.islower())) I’ve tried to put True = Sim and False = Não.…
-
0
votes1
answer54
viewsPython bitwise operator output
Why the value of ~True is -2 and that of ~False is -1? The logical operator equivalent not, in not True, results in False and vice versa.…
-
0
votes3
answers84
viewsDataframe Pandas - How to use a previous value other than NA for calculation
Having a dataframe as the following example: df = pd.DataFrame([['A',1,100],['B',2,None],['C',3,None],['D',4,182],['E',5,None]], columns=['A','B','C']) A B C 0 A 1 100.0 1 B 2 NaN 2 C 3 NaN 3 D 4…
-
0
votes0
answers91
viewsHow to access a shared folder on the network with password in windows using python
I have a program made in python that accesses my usb printer and then I have it print something, I’m trying to make my program access this connected printer on another computer sharing it on the…
-
0
votes0
answers16
viewsKeyboard python module: Supress = True/False, what’s the point?
Hello I was testing the module "Keyboard" in python and I did not find a good explanation nor in the module documentation about a parameter (if I am wrong correct me) called "Supress" in some…
-
0
votes0
answers15
viewsHow do I know if a list item is another list?
I’m wondering if it’s possible to check if an element of a list is another list, for example: lista = [0, [1, 2], 3] If possible, how do I go through this sub-list? for example, if I do: for…
-
0
votes2
answers823
viewsExtracting Data with Beautiful Python Soup
I made a Python script to access the TJ-SP website to do a certain search and make a Web Scraping with the search result. this is the HTML: i want to pick up the text that is contained in that tag:…
-
0
votes3
answers752
viewsHow to convert int variable to string without deleting zeros?
Need to perform in an activity the validation of characters typed by the user. My code: mes1 = int (input ('Digite o mês inicial:')) valida = len (str (mes1)) while valida != 2: print ('Valor…
-
0
votes1
answer23
viewsFilter model datetime Django
I have a model that is basically the following : class Sample(models.Model): date = fields.DateField(auto_now=True) Now, with this I want to filter only the month in this model How I only get the…
-
0
votes0
answers19
views[@action Django restframework ]: execute commands when a new client is registered
good night. I am developing a customer registration API, and I would like it that every time a new client is registered, runs something, and I tested a code and it didn’t work. someone can help me?…
-
0
votes0
answers19
viewsLoop to search Twitter for various elements of a list using tweepy
I am using tweepy to return 20 tweets from each user in INF_LIST. I’m trying to do this by way of a loop so that it covers all users. However, it seems that the program returns only the last user’s…
-
0
votes1
answer542
viewsplotly Candlestick in python
I built a Candlestick chart using the plotly and would like to know if it is possible to create on top of this graph, based on the column flag which contains the number 1, a rectangle superimposing…
-
0
votes0
answers21
viewsI want to save the data to a python text file, but the error occurs: Filenotfounderror: [Errno 2] No such file or directory: 'agenda.txta+'
#Quero criar um arquivo assim que o programa rodar pela primeira vez def novo_contato(): print('\n=== NOVO CONTATO ===') nome = input(' Nome: ') numero = int(input(' Número: ')) email = input('…
-
0
votes0
answers15
viewsRemove repeated python numbers
I’m not getting my program to print this output That’s the way out should be list = [2, 4, 2, 2, 3, 3, 1] remove_repeated(list) [1, 2, 3, 4] My programming for the problem is wrong, someone can help…