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
answer56
viewsPython recursive function printar correctly
I am starting in python and I would like the result of my execution to be as follows: [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 9 ] ] [ ’ ∗ ∗ ∗ ∗ ’ , ’∗ ∗ ∗ ∗ ’ , ’ ∗ ∗ ’ ] But I’m not…
-
1
votes2
answers282
viewsBuild list without repeated words from a file
I’m trying to create a program that reads a text file .txt and turn each line into a list. Then, with these lists, the program generates a new list with the words of the previous lists, without…
pythonasked 4 years, 7 months ago Magno Leal 47 -
1
votes2
answers577
viewsGroup three commands into one
My dataframe is called f0219. The following command filters a column of this df called Typorubrica when the code is equal to 2; this filter is assigned to the variable f0219Teto; Then, another…
-
1
votes1
answer217
viewsHow to check if a string is None?
I have the following code: st = "" if None == st: print True else: print False There is a form of the string st be equal to None in order to type the value on the screen True?…
-
1
votes2
answers264
viewsHow to round decimal numbers to the largest integer? python
I’m in need of arredondar values decimais for the highest integer value mais próximo of the relevant value. For example, I have the value... 22.6 ...and would like to receive as a result the…
-
1
votes1
answer39
viewsPython 3x - Error: "Object" is no defined in list
I am learning to program in python and I have this following problem in an exercise. When running the code happens this following error: vogal = (a,e,i,o,u) NameError: name 'a' is not defined. I…
-
1
votes1
answer54
viewsscapy installation without needing graphical interface or file . exe
Friends sweats, I’m having a little problem, I’m creating a python script with scapy and npcap (which is required for scapy to work) to run in windows. However, I managed to do the installation…
-
1
votes2
answers6846
viewsHow to cut string text in python by delimiting the initial substring to the final position?
I would like to know and understand how to return the cut in text with offset. I’m a beginner in python and I’m currently on a project to migrate from Delphi to python and there are a few things I’m…
-
1
votes1
answer437
viewsHow to import a function from a module in Python?
I’m having trouble importing the function of a module and making use of it. I already made sure to put the file __init__.py folder. But I can’t make use of the functions. The program will download…
-
1
votes1
answer345
viewsHow to create Stored Procedures mysql with python from aqruivos . sql
I have some files .sql where I keep a procedure in each file. An example, procedure1.sql: DELIMITER $$ DROP PROCEDURE IF EXISTS sp_teste$$ CREATE DEFINER=`db`@`%` PROCEDURE sp_teste () BEGIN UPDATE…
-
1
votes1
answer66
viewsRegex only in word without predecessor or successor of dots or bars
I would like to get the result of the occurrence without successor or predecessor of points or bar, I have my cases in the database: Registro 1: VERSION01/VERSION01.5/VERSION01.5.5 Registro 2:…
-
1
votes2
answers99
viewsHow to save multiple read values to be used later
Problem: "Read a sequence of 1000 integers. Read another integer N, and your program should print how many times the integer N appears in the previous 1000. The program stops when the first integer…
-
1
votes0
answers44
viewsPython & Arduino - Arduino does not restore my serial write() function
I am trying to communicate a python code and Arduin, but it is not returning the value to light the LED. Already all configured, Pip, pyserial etc. import serial import time import os conexao =…
-
1
votes2
answers245
viewsHow to remove a character-specific string from a Python string
I would like to know how I can remove a specific string string string. The string would be: \r\n. The texts are as follows:: 'Let the Bird of loudest lay r non the Sole Arabian Tree r nHerald Sad…
-
1
votes1
answer652
viewsPython - Tabuada- For Exercise - Matrix
Good night! I’m trying to create a tabuada program using for and matrix, my code is like this at the moment: def crie_array(rows, columns, value): matriz = [] for i in range(linhas): linha = [] for…
-
1
votes0
answers115
viewsError reading binary python file
good night. I am trying to read the contents of a binary file in Python to assemble a dictionary, but when reaching the end of the file the program is "flying" and I am not able to capture the…
-
1
votes1
answer327
viewsOrdering cards in Python
I have a list of the cards and the suit of a deck that I need to sort. Considering the correct order: A, 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K And the suits: P(clubs). O(gold), E(sword), C(hearts)…
-
1
votes1
answer217
viewsHelp with kivy (error: Attributeerror: 'weakref' Object has no attribute 'cline_in_traceback')
I’m learning the kivy (so I’m pretty virgin in the Gui subject) and I came across this mistake: important part: Attributeerror: 'weakref' Object has no attribute 'cline_in_traceback' full run: [INFO…
-
1
votes0
answers147
viewseSocialBX - targetNamespace invalid
We are trying to use eSocial BX to get some information about events sent. For the call ConsultarIdentificadoresEventosTrabalhador the following XML is sent (I removed the signature part): <?xml…
-
1
votes3
answers4131
viewsJoin columns in python?
Hello. I have this file (filing cabinet) where I need to merge the columns yyyy, mm, dd, hour (year, month, day and hour) into a single column, and stay in this format 20180101010000, conclusion:…
-
1
votes0
answers81
viewsImplementing Web Push Notification using Flask
I’m trying to create a way to implement a web push notification in my project. Using some tutorials I managed to generate an alert with the message I want. #!/usr/bin/env python from flask import…
-
1
votes2
answers2495
viewsHow to make an array with attributes or objects of a class?
Good evening, I’m a beginner in python and I have a question about how to make an array of an object or class. My main program contains a function that cuts into text, delimiting blocks and so on.…
-
1
votes0
answers54
viewsBreak lines in Paramiko (Python)
In my Paramiko/Python script, I need to receive broken data by lines. This data will be displayed on a web page. When I try this, the result appears on a single line, although it is several lines.…
-
1
votes0
answers50
viewsComputational performance metrics of a code
I made a time series forecast model, but I need to evaluate the computational performance of this model. I used the time (in seconds) as code below but it is not a good measure. Does anyone know how…
-
1
votes1
answer528
viewsTypeerror: randint() Missing 1 required positional argument: 'b'
My code is super simple: import random jogador=int(input('Qual é a sua jogada?\n1 - Pedra\n2 - Papel\n3 - Tesoura\nEu jogo: ')) jogador=random.randint(jogador) print('O computador joga…
-
1
votes1
answer58
viewsRemoving whitespace from a Numpy Array
I need to manipulate an image and identify the objects inside it. But the answer I get comes with white space and I’m not able to handle to remove these white spaces. Code: from imageai.Detection…
-
1
votes2
answers39
viewsDictionaries dependent on other dictionaries
Good afternoon, I have the following problem, I have to write a function that receives a dictionary and a subject and print all the dependencies of the subject for example : dependencias_complicado…
pythonasked 5 years, 6 months ago Thiago Andrade HoocKPeeR 29 -
1
votes0
answers28
viewshow to add headers to websockets (python)
I’m using the lib websockets python, and for me to make the connection (discord.com/api), he asks for a Authorization import asyncio import websockets async def connection_websockets(): uri =…
-
1
votes1
answer62
viewsReceive user data from
I made an algorithm to perform statistical calculations, I would like to put two options to the user: First, do the calculations with already sampled data within the algorithm Second, have the user…
-
1
votes1
answer190
viewsNormalizing values, what am I missing?
R s are matrices of the type [120.0, 77.34999999999998, 12.639999999999974, 39.270000000000074, 62.879999999999846, 54.549999999999656, 2.400000000000313, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0,…
-
1
votes1
answer105
viewsfind least repeated value in list
I have to draw a thousand numbers between 0 and 100, and point out which numbers were more/less repeated and the highest and lowest value, but I could not find a way to show what was less drawn.…
-
1
votes1
answer97
viewsCompare current time with file values
I’m trying to get a list of schedules of a file (I already got), and schedule according to the time: purchase scheduled for 15:30, at this time I will run the purchase (API.Buy) # alimentação sinal…
-
1
votes1
answer618
viewsHow to assign a css class in Django forms
Talk to the guys, all right? So today’s fat is the following, I want to add by default a css in my forms generated in Django, I searched some things but nothing solved my "problem". I was wondering…
-
1
votes1
answer21
viewsWhen a repetition is made in case there is no answer, no change is made! pq?
It’s a simple code, but based on what I’ve seen and been studying about repetition structure right here, I’ve come up with a way to do it, but I’m dealing with the following problem: the value is…
-
1
votes0
answers147
viewsHow to use Thread in my project with Tkinter and Selenium
I’m making a bot to get the free books that Amazon made available, so I created a graphical interface, but after discovering that Tkinter does not work the way I wanted, it also stops working when…
-
1
votes1
answer77
viewsMy Ry is not reading my except
while True: try: idade = int(input(f'Digite a idade da pessoa {c+1}: ')) except ValueError: continue else: if idade < 18: listaidademenorde18.append(idade) elif idade >= 18:…
-
1
votes0
answers41
viewsPython syntax {%-- %}
Good evening, I’m doing the tutorial of Django’s documentation and I came across this code: {% if latest_question_list %} <ul> {% for question in latest_question_list %} <li><a…
-
1
votes0
answers50
viewsRead text in a specific image location
I need help trying to read a text in a specific part of the image. The intention is to identify a specific product among several equals, but the only thing that changes is the text present in it.…
-
1
votes2
answers72
viewsAccountant who does not count
Hello I did the following program: #!/usr/bin/env python3 # -*- coding: utf8 -*- import datetime import os import sys ref_arquivo = open("trata.txt","r") for linha in ref_arquivo: valor =…
-
1
votes0
answers39
viewsHow to create a column based on another dataframe?
I would like to know how to create a column on a dataframe based on the code of another Python dataframe. For example, I have: df A: letra c b d c a df B: letra codigo a 10 b 20 c 30 d 40 Expected…
-
1
votes2
answers65
viewsHow to use the filter function using lists?
I am trying to filter the months with only 31 days, however mdays is a list and I need to compare with an integer value. Taking the Dice, it becomes an integer value, but then I don’t know how to…
-
1
votes2
answers2087
viewsHow to draw numbers from a list, randomly and without repetitions?
How do I draw 9 numbers in a list of 15, without repeating the numbers drawn? I use Python 3.8. import random for c in range (1, 16): n1 = str(input("Digite um nº: ")) l = [n1] random.shuffle(l)…
-
1
votes2
answers237
viewsHow to get the name of the python function parent
Fala, Povo! I have a log - add_log() - add function that takes a title, status and Obs to register in a txt file along with the time. I wonder if there is any way to get the name of the parent…
-
1
votes1
answer52
viewsWhich Timezone to use for apschedule?
I’m trying to schedule a task for weekdays, from 8hrs to 17hrs, every ten minutes, using the apscheduler module. from apscheduler.schedulers.background import BackgroundScheduler cron =…
-
1
votes0
answers92
viewsProblems in the Results print()
I’m writing a code that calculates probabilities based on a particular Excel database. When doing this in Excel I have the final result in the column "Probability3 %": Now I need to do the same, but…
-
1
votes1
answer92
viewsWhere to place mathematical models in Django
I’m new to the subject, so forgive the ignorance. I am developing an application using python in Django, where from user informed data the application will return certain values. But I am in doubt…
-
1
votes2
answers6875
viewsDataframe - Pandas. Assigning values in columns from comparing another column
I have the following Dataframe: import pandas as pd df = pd.DataFrame({'id_emp': [1,2,3,4,1], 'name_emp': ['x','y','z','w','x'], 'donnated_value':[1100,11000,500,300,1000],…
-
1
votes1
answer113
viewsHow to change parameters of a class within a thread
I am initiating a class in the global scope, then I create a thread that alters a parameter of this class. After closing the thread I ask the class what parameter value I just changed, it tells me…
-
1
votes4
answers92
viewsField match, referenced in previous field
I started learning about Python from Jango and am trying to develop a simple vehicle management system. I am beating head to perform the following procedure: as soon as the registration plate is…
-
1
votes1
answer231
viewsPython file batch problem when activating windows task manager
I made a batch file to run a small script in python, it works normally, but when I use windows task scheduler to trigger the batch at a specific time it presents the following error: Where you say…