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
answer3049
viewsIncreases font size in python and how does the number of decimals decrease?
print ('Área da seção transversal:',Acf,'m^2 \n') print ('Velocidade média:',Vf,'m/s \n') print ('Número de reynolds:',Re_f,'[adimensional] \n') print ('Número de nusselt:',Nuf,'[adimensional] \n')…
pythonasked 5 years, 8 months ago Lucas Almeida 19 -
1
votes1
answer75
viewsVariable loses value inside "for"
a=2 for a in range (9) : print (a+1) Why using the for, in this case, it is printed from 1 to 9, and the variable a is equal to 2?
-
1
votes2
answers437
viewsRegex to find text between square brackets
I’m trying to create a regex to identify the following occurrence: [Ticket: 20021501280806] I need an expression that identifies the ticket number, but only within the string [Ticket: ]. Actually I…
-
1
votes1
answer4919
viewsComparing column values in dataframe pandas rows
Good afternoon. I am comparing two given frames, data frame 1 has an sql query and data frame 2 a mysql query I want to compare the two. When the DF 1 record is not in DF 2 I want to save the result…
-
1
votes0
answers49
viewsHow to import a huge CSV into Python?
Hello, I’m working on a enrollment file for the School Census. I want to import in Python but none of the answers I’m looking at are working. pandas pd.read_csv() takes a long time and cannot open.…
pythonasked 4 years, 9 months ago Jessica Voigt 883 -
1
votes1
answer85
viewsWhat is the purpose of the "Pyobject" structure and what are the objectives of its members?
I’m analyzing the structure Pyobject of Cpython. The code for this structure follows below. Structure PyObject: typedef struct _object { _PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt; struct _typeobject…
-
1
votes2
answers422
viewsFinding students without a class - Python / Excel
I have a spreadsheet in Excel with all my students and their respective grades (5th to 9th). I need to find all my students who aren’t in any class. Through the Excel filter I can do, but I have…
-
1
votes1
answer593
viewsPass view arguments to Django form
Hello, good night! I’m doing a question and answer application on Jango and I have basically these models: Multiple choice app: class MCQuestao(Questao): def checar_correta(self, ans): answer =…
-
1
votes1
answer155
viewsConvergencewarning in the Lasso CV method - What can I do to solve the problem?
Could someone help me with this mistake? Convergencewarning: Objective Did not converge. You Might want to Increase the number of iterations. Duality gap: 3.5998713265016704, tolerance:…
-
1
votes1
answer97
viewsSum variable is accumulating the value instead of starting at zero
The algorithm is for the customer to place orders in a snack bar, he asks for the name of the customer - 1, then the order quantity and then the algorithm asks to enter the order number, when the…
-
1
votes1
answer578
viewsInsert or update Posgresql via Python
Today I am using the following code to call via API and store my data in the Postgresql database: conn = psycopg2.connect("dbname='DBNAME' user='USER' host='HOST' password='PASSWORD'") insert =…
-
1
votes3
answers362
viewsFunctions with optional Python parameters
I want to create a function that has the first optional parameter. For example: the function range([start, ] stop [, step]) Thus, if only one argument is passed it is considered as the second…
-
1
votes3
answers627
viewspass list of one method to another in python
I have two functions, I need the list of the first to be read by the second, the two are in a view of Django, that each generates a different template. class Tranfer: shared = [] #Essa proprieda…
-
1
votes2
answers205
viewsStore read names in a list and randomly choose one of them
How do I, among the students I type, he draw one within the range? In the code below it does not draw, returns me only the last name: from random import choice for c in range(1, 4): aluno =…
-
1
votes3
answers2356
viewsAccess data from a JSON structure
I’m having some problems trying to access some data in a JSON structure. The JSON code is this: [ { "teste":[ { "dados":"teste", "uno":[ { "um":"Teste", "cores":[ { "preto":"Preto",…
-
1
votes1
answer64
viewsArq.readlines python / Tkinter loop
I’m new in Python and I’m doing a report and I’m not getting a loop to read a txt file that I have. the data from the txt file are: ('001','0:59:30.0','1','3.00') ('002','0:59:30.0','2','4.00')…
pythonasked 5 years, 8 months ago Rodrigo Aruake 15 -
1
votes2
answers150
viewsRegular expression validation is invalid even when you find a match
I’d like to know what’s wrong with that code. All valid values I enter in the name, email and phone are invalid, even if in the format requested by regex. import re class Contato: def…
-
1
votes1
answer52
views"except" does not recognize value as wrong
mensagem = input('''Clique "C" ''') print (mensagem) #condições relativas ao input mensagem try : mensagem == "C" except Exception : print ("a casa caiu") else : print ("a casa não caiu") The…
-
1
votes2
answers444
viewsVirtual Assistant
Good afternoon fellows, as you go? So I’m fairly new to this development environment and I programmed in python some time ago. I have a project idea where it involves creating a kind of virtual…
-
1
votes2
answers1298
viewsHow to create a dictionary through a string
Good afternoon, I wonder if it is possible to create a dictionary through a string, for example: I create a loop for inside a list and this loop will always give me a name: lista = ['ameixa',…
pythonasked 5 years, 8 months ago Filipe Gonçalves 236 -
1
votes1
answer485
viewsHow to capture parameters of the object that called an event in Tkinter?
I have 3 buttons, two with the same name and one with different name and each with its properties, I would like to know how to capture the text of each button in the same definition. Of course, I…
-
1
votes1
answer242
viewsMatrix transposition
want to understand the meaning of the tuple that the following code passed inside the command . transpose, I went after the documentation but it was not clear to me: arr = np.arange(16).…
-
1
votes0
answers38
viewsGroup by column-specific values in a Dataframe
I have the following dataset: Brand Condition Fuel 0 Toyota Used Diesel 1 Suzuki Used Petrol 2 Suzuki Used CNG 3 Suzuki Used Petrol 4 Toyota Used Petrol It’s over 10,000 records and has over 15…
-
1
votes1
answer5585
viewsAttributeerror: 'Cursoprogramming' Object has no attribute '_valuations'
I’m developing a little Python "online course site" system, and there’s an error that, at least for me, doesn’t make sense. Follows the code: from src.site.classes_de_alunos_e_professores import…
-
1
votes2
answers143
viewsFind arrays with the shortest distance
I have a array_objetivo and would like to find the id and the distance (Euclidean in this example) of n arrays closer to him that are in array_all. Following are examples of arrays. array_objetivo =…
-
1
votes0
answers42
viewsReading Table in Python with Beautiful Soup
I need to get a table of the transparency portal to then write to the database. I am using Beautiful Soup. I can’t bring in the request the part that has the data and consequently no tag that I look…
-
1
votes1
answer96
viewsSubtract values using sqlite in Python
I want to do the following: Create a function with a quantity parameter, thus causing the value of the parameter to subtract with a value from a table field: Example: sell(5), this 5 will subtract…
-
1
votes5
answers3780
viewsI want to know how many rows and columns an array has in Python?
I am trying to develop an exercise that requires the creation of a function that when it receives as a parameter an array, it returns the number of row and column that this matrix has. I’m trying to…
-
1
votes1
answer61
viewsFunction within a function
I’m doing some tests and I’d like to understand why when my role somadez() is called is returned to me that function soma() was not defined being that the same when it is called works. Follows the…
-
1
votes1
answer490
viewsConvert function arguments to string
How to convert function arguments to string? Without having to type all arguments I tried to solve it this way: def teste(a, b, c, d, e='F9', f=1): for key, value in locals().items(): key =…
-
1
votes1
answer59
viewsWhat is the error in the Python chart
When I put print on file 2 it displays me the data from the first'file' import urllib.request import pandas as pd import datetime import matplotlib.pyplot as plt origem =…
-
1
votes1
answer101
viewsData munging with python
Are the following date formats: 042555 04/25/1955 Abril 25, 1955 How to use regex to transform a date format into each other (would be 6 transformations)? For example: Entrada: 042555 Saída:…
-
1
votes2
answers94
viewsHow to name the keys of a dictionary from a list (array)?
If I have a dictionary of this kind: dados = {"indice1": [1, 2, 3], "indice2": [4, 5, 6]} and want to name its keys: indice1, indice2 with the following array: names= ['nome1', 'nome2'] I can do…
-
1
votes1
answer730
viewsRead a JSON file and print the data in tabular format
The file is "grids.json", whose structure is: {"students": [{"name": "Alan", "lastname": "Silva", "exam1": 50, "exam2": 80, "exam3": 91}, {"name": "Paula", "lastname": "Souza", "exam1": 95, "exam2":…
-
1
votes1
answer42
viewsWxpython: Getfocuseditem() returning item even with nothing focused
I’m writing an interface with wxPython, but I’ve come across a problem so far with no solution, even looking at the documentation. I have a Listctrl with several items that should be sent to the…
-
1
votes2
answers86
viewsHow would you solve this simple question?
I was solving a simple Python question The program asks for three numbers and returns in descending order - I decided to do it using a list, like this: numeros = [] for i in range(0,3):…
-
1
votes3
answers155
viewsHow do I catch a backend error and not log into the application?
Guys, good night, I researched several topics and tried several solutions and unfortunately I could not adjust the error. I am developing an application with Angular and my Python backend, at the…
-
1
votes2
answers525
viewsFind and Extract a line or words from a source code with Python 3
I need to write a script that can extract a certain line in a source code with Python, I was able to read the source code, but I can’t filter, I’ve read the documentation and I got a little lost. So…
pythonasked 5 years, 7 months ago Renan Levinski 11 -
1
votes1
answer38
viewsProblem with opencv on linux
I’m making a monitoring system with Opencv Python via streaming on my Windos 10 OS runs all correctly by irony on my Linux Mate I get the following error message when I try to run Nonmatching…
-
1
votes0
answers187
viewsHow to authenticate with token (JWT)?
Good night, you guys! I have tried 3 different ways, but the closest I got was the code I will post below, I am developing an application as a study using Angular and Python and currently I already…
-
1
votes0
answers427
viewsHow to extract Header Token to store in Local Storage?
Good night, you guys! I’m in a battle to get back the token I send from my backend to my browser. Follow my Back code in Python: class Login(Resource): def post(self):…
-
1
votes1
answer85
viewsHelp for Linear Dilation calculations in Python
Hello. This is my first post on Stackoverflow so a thousand pardons if I ever make a mistake. Guys, can you help me? I’m trying to develop a code in Python that can calculate the Linear Dilation of…
-
1
votes0
answers153
viewsHow do I get my token in the header?
Guys, I’m 'stuck' in this part of the code, I’m generating my token pro browser but I can’t access it to save in my localStorage. I can’t, in any way access my header this way, every time returns…
-
1
votes1
answer360
viewsHow to limit the number of threads running at the same time?
I’m trying to create a proxy checker using multithreading, this is my code: import requests import threading from time import sleep from colorama import Fore url = 'http://google.com' proxyList =…
-
1
votes4
answers2686
viewsCreate multiple lists containing random numbers
How can I create a code that generates 50 lists with 12 random elements? I’ve tried to use while to repeat a list generation function, but it did not work very well. import random def…
-
1
votes2
answers68
viewsHow do I show the wrong input numbers?
In this code I would like that if the student enters some wrong note, the program responds which grades are wrong. But based on what I did only appears the first note. I also wish that when typing…
-
1
votes1
answer208
viewsNeural Networks can’t Multiply Sequence by non-int of type 'float'
Hello, I need to implement a perceptron to linearly classify 2 species (Iris). I’ve already scoured the internet for solutions and I can’t get out of the problem I took a code on the internet and…
-
1
votes1
answer297
viewsSave a file using a view function on Django
I have this following HTML, which is a form with an input for a file and Submit button: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document…
-
1
votes2
answers978
viewsHow to return a json to the same Django template?
I am trying to return a json to the same template without rendering it again (as in the case of render(request, 'dir/base.html, Response))) using Jsonresponse, but it is giving this error: Object of…
-
1
votes1
answer357
viewsCheck existence of Python file with function
I searched all the repositories corresponding to my doubt here, but all are very direct when creating and reading part of files in Python, but I saw nothing related using function. Function to…