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
votes0
answers184
viewsredirect is not sent to the browser
I made 3 pages on my website: one to register, one to login and another serving as the home page. I need that after the user registers it is sent to the login, that if successful send it to the home…
-
0
votes1
answer1174
viewsCartesian plans in Python
Good evening, good afternoon and good morning. I am 15 years old and am studying about second degree equations, Cartesian plan and functions. Because of this, I made a code to calculate the roots,…
-
0
votes2
answers33
viewsCheck whether a variable created through exec() exists
Good evening, create an excerpt from a script that performs the creation of a variable through exec(), however, how can I verify that the variable exists through a for in range? # criando a…
-
0
votes1
answer75
viewsPYTHON LAYOUT ATTRIBUTE ERROR
I’m doing a project in Python with Pysimplegui using Sg for simple layout, but the Pycharm terminal returns me the error of missing value assignment tried to go through the powershell terminal and…
-
0
votes1
answer161
viewsHelp with Django Template Directory
Guys, starting to study Python with Django now and a doubt has arisen here that I can not solve. django.template.exceptions.TemplateDoesNoteExist: home.html Views.py from django.shortcuts import…
-
0
votes1
answer503
viewsPython and Kivy: How to select and copy all text from a Text Input
Hello! I’m trying to learn Kivy... 1) I would like to select all text within a Text Input in Kivy. Which attribute should I study to change my code myself?; 2) After selecting all the text, the copy…
-
0
votes1
answer61
viewsHow does the declaration of a class in Python handle the external scope?
To illustrate, let’s consider this class statement: x = 1 class Foo: a = x b = [x] c = [x for _ in range(1)] print(f'x = {x}') # x = 1 print(f'Foo.a = {Foo.a}') # Foo.a = 1 print(f'Foo.b = {Foo.b}')…
-
0
votes1
answer84
viewsHow to print typed text in a Tkinter GUI on the console?
I wanted to create a text in a window and, pressing a button, my text appear on the console. My code is this: from tkinter import * class janela: def __init__ (self, janela): self.frame=Frame()…
-
0
votes1
answer70
viewsHow to return an attribute from a class based on the minimum and maximum of other attributes of the array?
Hello, I would like to know how I can go through the vector of objects and return the name of the company that has the smallest amount of employees and the name of the company that has the largest…
-
0
votes0
answers217
viewsHow to make a socket connection using Hamachi in Python?
I’m trying to connect with socket on another network with Hamachi. When creating the server, I am using the local IP and when connecting I am using the Hamachi IP. See my code below: # Código do…
-
0
votes1
answer249
viewsValidation in the constructor - Python
I made this class however, when I enter values that in theory should not be allowed it continues running normally, even having created a function that makes the validation. I can’t get it inside the…
-
0
votes2
answers109
viewsIterating a string inside the for
As for can pick up the string backwards using Len with -1 -1 -1? nome = 'felipe' for c in range(len(nome)-1, -1, -1): print(nome[c], c)…
-
0
votes0
answers54
viewsProblem collecting website information
I am trying to collect the data number of people helps in SOPT, ie my impact, to put in an api later, but is not extracting the information. Spider: import scrapy class StackOverflow(scrapy.Spider):…
-
0
votes1
answer69
viewsCreate multiple Dataframes through iteration
Is it possible to create multiple Dataframes within an iteration? I need to do this feat, follow the example: in the NUM iteration, it has numbers from 0 to 9, total 10 numbers. in the for nn in…
-
0
votes1
answer71
viewsOrientation to Python Objects
How to make the only way to insert the days, months and years are solely and exclusively done by the setDia() method, that is, when instantiating do not want to pass values to these attributes at…
-
0
votes1
answer125
viewsScreenshot in Python
Hello! My problem is this: I want to make a screenshot of my pc screen using python, I can even beat the screenshot, however, the screenshot is only saved after running the program, I say, the print…
pythonasked 3 years, 10 months ago user218366 -
0
votes0
answers157
viewsExtract numpy arrays from a dictionary iteratively
I have a dictionary of the following kind: data = {'neuron4':Numpy array, 'stim':Numpy array, 'neuron3':Numpy array, 'neuron2':Numpy array, 'neuron1':Numpy array} I tried to do something like for…
-
0
votes0
answers162
viewsI can’t file a request for flask through the angular on apache
[RESOLVED] I managed to solve. I used Proxypass to redirect meudominio/api requests to localhost:8000, and changed the request url in my angular project to meudominio/api, and then it started…
-
0
votes1
answer794
viewsFind element input inside the Python matrix
I’m trying to locate a number’s index inside a list of pre-established lists. The program recognizes the number but says it is not on the list.…
-
0
votes2
answers704
viewsError: Unsupported operand type(s)
I come from language C and I’m trying to sum up the values of a list. But after declaring I cannot use the function sum() and the other methods. Python tells me that I can only do operation on…
-
0
votes1
answer69
viewsTypes like list and str are all primitive types?
Lists, tuples, dictionaries, integers, float, bool, etc. are all primitive types or composite variables are different?
-
0
votes2
answers473
viewsHow to automatically populate a table field with a foreign key?
Good afternoon! Guys, I made a form where I take the data from this form and send it to two related tables. One of them is the registration table (only with personal information) and another address…
-
0
votes1
answer259
viewsPython - stack - - balancing
I can’t find the error in this code: A sequence of parentheses "(" ")", brackets "[" "]" and keys "{" "}" is said to be balanced if each "open" symbol is "closed" at an appropriate time For example…
-
0
votes2
answers647
viewsCalculate how many times the values are repeated inside a dictionary KEY - PYTHON
I have a dictionary that is created from a select in the database, what I needed was to generate a metric from that dictionary Dictionary # cria dicionário do banco de dados com os valores lds_data…
-
0
votes1
answer132
viewsHow to handle "Nan" values returned from a Dataframe
I wrote the code below to select 1 column of each CSV file, but it returns all values like NaN. How I treat it so it returns the right values? import pandas as pd df1 = pd.read_csv("CSSS.csv",…
-
0
votes1
answer90
viewsThreads do not run - Python
I need to allocate several threads to process a given data array. However, regardless of the number of threads I allocate, one of them is always unexecuted (usually the first). Follows code snippet:…
-
0
votes1
answer63
viewsRed numbers in Visual Studio
I was testing the Python Colorama library and it occurred to me, does anyone know why? I can not run at all, this error appears: print (\033[33m'hello') ^ SyntaxError: unexpected character after…
-
0
votes1
answer815
viewsSave array to python CSV
I wrote the code below to store some data in a dataframe, soon after I converted it into an array, but when saved the same in CSV file, the same jumps lines in saved file import pandas as pd import…
-
0
votes1
answer1016
viewsSearch for e-mail or word within a webdriver site in python?
Hello, I am wanting to create a Bot to enter a website and search if that site has an email to contact and create an email list ... the problem is that this can all be very generic.. on some site…
-
0
votes2
answers409
viewsSend JSON with python to API
I’m putting together a list of objects to post to an API in made in Arabic, but I can’t convert the data to work on the API. In python the list of objects is something like: payload = […
-
0
votes3
answers228
viewsCompare two lists in python and return matches
How to compare (old-fashioned) 2 lists in python and return the matches of these two lists
-
0
votes1
answer234
viewsJoin several. nc files?
I’m a beginner in python and work with Data Analysis applied to Oceanography and I’m having difficulty working with reading files . nc ! Is the following: I have 30 . nc satellite data files, each…
pythonasked 5 years, 2 months ago Victor Huggo Lessa Rosolem 1 -
0
votes2
answers72
viewsHow do I store data and not delete when the program ends?
How do I make sure that when a data is stored, it is not deleted from the program ending? for example: LISTA = ['Morango', 'Abacate'] ADD_ITEM = input('Digite algo que deseja adcionar:')…
-
0
votes2
answers62
viewsHow to use print for special Python characters?
When trying to use print for a special character, I get the following error: print('\') File "<ipython-input-38-eaac87876c3b>", line 1 print('\') ^ SyntaxError: EOL while scanning string…
-
0
votes1
answer39
viewsFile list gives errors when going through . Decode()
In the following code for file transfer using Python sockets: Client: lista_arquivos = ['C:\Users\fulano\Imagens\passaro.jpg', 'C:\Users\fulano\Imagens\cachorro.jpg',…
-
0
votes1
answer85
viewsIs it possible to use python’s LIB socket to make communications as a websocket?
Hello, sorry if there is any error, I am creating an MMORPG with the engine Construct 2 and it only has a plug-in websockets, however I tried to use the lib websockets from Python, but I don’t think…
-
0
votes1
answer71
viewsValueerror error: 1 Columns passed, passed data had 12 Columns
I’m trying to make a Dataframe but I get this error:Valueerror: 1 passed, passed data had 12 Columns. Here’s my code: import pandas as pd colunas = ['Legenda'] conteudo2 = [['Pontos…
-
0
votes1
answer98
viewsError Selenium python, cannot find element
I am trying to use Selenium to make a python script to automate Twitter login. However, I am always getting this error: Unable to locate element. Any page element appears this error, I try to find…
-
0
votes1
answer150
viewsHow to encode a number with the notation x and not 0x
Problem I’m performing a serial communication in which the checksum the message needs to be sent or verified upon receiving. This must be checked with a XOR logic, which returns an int number, given…
-
0
votes1
answer41
viewsI need to change the output of a variable in Python
My variable a, imported from a file .mat, has as output: array([[0],[1],[2],[3],[4],[5]]). I need the output of the variable a be it: array([0, 1, 2, 3, 4, 5]) How do I make this correction/change…
-
0
votes1
answer70
viewsConversion of PDF images with Python
I am trying to convert all images from a directory into a single PDF. However I am having difficulties. When I run my system it gives the error below, it tries to read the file . py also. from PIL…
-
0
votes1
answer86
viewsReturn brown percentage in image
I have a code where I take a video and save an image every 20 frames and I take a slice of that image, until then I was able to do it, but I need to analyze if they have pixels with the same or…
-
0
votes1
answer38
viewsHow can I make a Python timer that at the end of the timer emits any sound?
import time def tempo(): time.sleep(10) print "Ola"
-
0
votes0
answers35
viewsNPM INSTALL SQLITE3 (Python) error
Good night, you guys! I’ve exhausted my attempts. I installed python 3.9 added in the environment variables, uninstalled the project’s node_modules and package.json installed node_modules again and…
-
0
votes0
answers55
viewsIs it possible to call a Setter inside a python class method itself?
I have a class that reads an XML file and with the file information fills the class attributes. All the data consistency checks I do within the "setters" of the attributes (the class can be used…
pythonasked 5 years, 2 months ago Fernanda Foschiani 1 -
0
votes1
answer114
viewsPython and Mysql tuple search
Hello, Good Night!!! I am new to Python programming, and recently I received a job in college to implement a program similar to Akinator, using the desired language, because it is easier, I decided…
-
0
votes1
answer146
viewsHow do I run a web routine within Tkinter without crashing the mainloop?
Good day I created an application by Tkinter and now I’m trying to make the information on the web available to users in real time. The problem is that the app.run function does not let you run the…
-
0
votes1
answer42
viewsVariable sum does not take the value within the loop!
print ("Produto Numero 1") ValorDaMercadoria = float(input("Qual o valor da mercadoria? ")) print("Produto 1",":",ValorDaMercadoria) NumeroDoProduto = 2 ValorDaMercadoriaLaco = 1 while…
-
0
votes1
answer75
viewsHow to detect that two bodies (in my case, balls) have touched while they are moving?
I’m doing a program in python that simulates a small game of billiards (pool) and I’m having trouble finding a simple way to identify when the two balls touch, so I can change their direction. My…
-
0
votes1
answer70
viewsImplicit recursion when assigning the return of a function to a variable?
Speak guys, I’m starting studies in Python and I came across a behavior a little strange for me. It’s this: I have a file test py. which contains some functions. In another file, exempl1.py imported…