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
votes2
answers33
viewsProblems making the POST in Django
I am in a part of the project, which is the page of records I created the View method but it’s not rolling yet From what I looked the button is ok. The last image is from my admin, where the new…
-
-1
votes2
answers17
viewsAdjust columns in Tkinter Table
I’m using Tkinter in Python, and also using Table. In my code I have a line, as follows: table = Table (frame, dataframe=frame_input['id', 'name', 'usando_limit', 'telephone']], width = (width -…
-
-1
votes1
answer27
viewsHow do you make a login button that opens a new window?
I was trying to make a program, with a login system, but I couldn’t get the commit button to access my 2° window (in case I would need the login to be right for this to occur). Thanks in advance.…
pythonasked 3 years, 8 months ago Davi Rafacho 1 -
-1
votes1
answer5701
viewsSyntaxerror: Unexpected EOF while Parsing
My program is giving "Syntaxerror: Unexpected EOF while Parsing", my teacher said it would be by not closing the while, but I can not, I tried several ways, still giving error class Conta: def…
pythonasked 5 years, 1 month ago nascimento 1 -
-1
votes1
answer93
viewsHow to return a string transformed column to a float, int?
I had to turn a column of a database into a string in order to remove the last digits of the values, which were 0.1, 0.2 or 0.3 and this would disturb my data in the future. However, by trying to…
-
-1
votes1
answer55
viewsHow to compare if a number entered by the user is equal to a certain value
I have this code: idade = input('Qual a sua idade? ') if(idade == 33): print('Ok, não parece que você está mentindo.') else: print('Você tem certeza que não pulou alguns dígitos?') Regardless of the…
-
-1
votes1
answer94
viewsDjango authentication
good afternoon! I’m starting in WEB programming and I ended up bumping into a problem with Django in the authentication issue. I’ve read all the documentation that talks about Django’s Custom Auth…
-
-1
votes1
answer37
viewsFlask import problem (Unable to import 'controllers' pylint(import-error)
Good evening, I’m starting to program now and I’m trying to make a simple system using the Flask framework, but during the organization of the files I came across the problem of the title, I’m not…
-
-1
votes1
answer53
viewsI need to find the duplicates inside a CSV and count them
I am trying to read the amount of repetitions in column A and B of a CSV and see the amount of times A and B are equal as the example below: input: [email protected] |…
-
-1
votes1
answer79
viewsGet from a list all indices whose element is equal to a certain value
This is my code: def procuras(lista,valor): dicionario = {} for valor in lista: if valor in dicionario: dicionario[valor] = [i for i, item in enumerate(lista) if item == valor] else:…
pythonasked 5 years, 1 month ago PipocaInsuflada 5 -
-1
votes1
answer104
viewsPython script that reads a Json and converts to a javascript
Hello I would like a help, I have a json that I can pick up from the web or download into my linux... and I need to build a standard code from this json. I need to mount an always standard…
-
-1
votes1
answer677
viewsHow to pick up element xpath in span
I am using lxmlalong with Python 3.8and I’m needing to take the xpath of a text that’s inside that part of html: <span class="text-down">7424.65</span> The xpath is:…
-
-1
votes1
answer31
viewsHow to compare if the value of a dataframe column is in an array if you are creating a new column with that value?
lista = array(['NF', 'BT', 'C', 'N', 'I', 'IP', 'Aa', 'Sa', 'Gl', 'Et', 'To', 'Hr', 'Cr', 'Ro', 'X', 'Oa', 'Ml', 'Me'], dtype=object) "DATAFRAME" x_1 x_2 0 NF 0 1 A 0 2 B 0 3 KK 0 4 Gl 0 5 Oa 0 The…
-
-1
votes2
answers573
viewsPython / Pandas - error reading Arq. csv ( path)
I’m using Google Colaboratory and trying to read a CSV file, separated by ";" and is giving the following error. I think it has to do with the path. What I’m doing wrong? import pandas as pd…
-
-1
votes1
answer186
viewsAutomation in HTML [Python]
Good morning, good afternoon and good evening friends Devs. Just making it clear I’m a beginner -- I have two questions about automation within Python. 1- I want to do an automatic login on a given…
-
-1
votes1
answer59
viewsGave error "list index out of range" and do not understand the reason
notas = [10,5,6,7,8] for i in range(0,len(notas)+1): print(notas[i]) Made the mistake: line 4, in <module> print(notas[i]) IndexError: list index out of range…
-
-1
votes1
answer70
viewsHow to read a csv file by pandas without erasing the first number?
Hello, I have a.csv file and I want to read with the pandas library in Python. When I run the command it takes the first 0 from the sequence of numbers. Can someone help me with this? I want him to…
-
-1
votes1
answer41
viewsString Size Using Lists
How do I print the size of each of the strings the user types? Every time I ask to print out how many strings are inside the list and not the number of characters of each string inside lista = []…
-
-1
votes1
answer42
viewsAdd data within a dataframe based on a condition for two columns
I have a DF with four columns. I need to add the values of column 3 when the values of column 1 and 2 are duplicated and discard duplicates. Ex: df = pd.DataFrame({"A": [1,1,1,1,2,2], "B":…
-
-1
votes1
answer723
viewsValidation of the last 2 digits of CPF in a single loop for
I checking the last two digits for CPF validation. I made the code, but it’s just calculating the first digit. I’m not getting, include in the same loop to calculate the second digit: while True:…
-
-1
votes1
answer358
viewsHow to Manipulate Strings in Python
I was wondering how I can manipulate Python characters. In C, I can do this by adding 1 to a character, if I type "a" for example, it adds 1, and "a" will become "b". Example: char string[20];…
-
-1
votes1
answer35
viewsWhat is the use of nested classes in python? for which I would use something like that?
I can’t find much python-like, I know you can do that and I know how to do it, but I don’t know why anyone would want to do that, since the inner class is unable to access the attributes and methods…
-
-1
votes1
answer75
viewsWhat is the difference between "/" and "%" in python?
x1 = int(input()) v1 = int(input()) x2 = int(input()) v2 = int(input()) if x1 == x2 and v1 == v2: print('SIM') elif (x1 == x2) and (v1 != v2): print('NÃO') elif (x1 - x2) % (v2 - v1) == 0: if (x1 -…
pythonasked 3 years, 5 months ago JoaoHardline 11 -
-1
votes1
answer43
viewsSet a runtime variable from a string and a python object
I want to add a variable to my code or in memory at runtime, I’m looking for something like this since yesterday and can’t get the desired result. Let’s say I have an object: (<bound method…
-
-1
votes1
answer216
viewsInvalid syntax in Python, what’s wrong or missing?
print('{:=^40}'.format(' SIMULADOR DE JUROS COMPOSTOS ')) print(''' ESCOLHA A OPÇÃO [1] Para Juros [2] Para Capital [3] Para Taxa [4] Para Tempo''') opção = int(input('Qual a…
-
-1
votes2
answers288
viewsMake the program go back to the beginning
I’m doing a César encryption encryption. I kind of make the program go back to the beginning. Code: tela=input('Com isso Coloque uma palavra ou frase para ajudar no comprometimentoao meio ambiente')…
-
-1
votes2
answers315
viewsHow to avoid code repetition to average a variable amount of banknotes
I created a simple script to make it easier to average students. The problem is that I might need a while to repeat the code. I wanted to make sure that when I finished displaying a student’s…
-
-1
votes1
answer17
viewsSave the number of rows of a dataframe to a variable
I have a dataframe that is generated randomly by varying its number of lines. I would like to save this variable number for future use. Follow the example of dataframe: And I’d like to replace the…
-
-1
votes1
answer350
viewsScreen system by console (python)
I am developing a text-based RPG (I am still very beginner and I am applying my learnings in this little game), and I would like to know if there is any way to create 'displays' within the console…
pythonasked 5 years ago Rodrigo Moreira 11 -
-1
votes2
answers1584
viewsHow to insert data from one dataframe into an index present in another?
I have a folder with about 480 CSV files, only they don’t have an index and I created another CSV file to be their index (there are 119 columns in the index) When I enter using df.append the file…
pythonasked 5 years ago Matheus Jarel 1 -
-1
votes1
answer22
viewsHow to make a call from a script that is in another folder
I am developing a process in which it will be necessary to make a call in a script that is in another directory. I have a script that is in the directory /home/ant/tests/mobile/myphone.sh If I…
-
-1
votes1
answer115
viewsError in the self.bntInsert["command"] = self command
Hello guys as I am new in python need a help in this code this with the following error File "/root/Pycharmprojects/Sistemavenda/venv/App.py", line 113 self.bntInsert["command"] =…
-
-1
votes2
answers50
viewsOverwriting the occurrences of a string in a text file. Differences presented with several file opening modes
The goal is to replace each occurrence of the word "secret" with "XXXX" in the Crypto.txt file. My code: def crypto(arquivo): #palavras = [] with open(arquivo,"r") as crypto: data = crypto.read()…
-
-1
votes1
answer25
viewsHow to remove duplicate names in rows from a python dataframe?
Hello, everybody. I have the following dataframe: df = pd.DataFrame({ 'Codigo': [1, 2, 3, 4], 'Nomes': ['Alan Silva, Alan Silva', 'Carlos Santos, Carlos Santos', 'Joao Pedro', ' João Pedro'], }) df…
-
-1
votes1
answer24
viewsRemoving non-numerical value from a dataframe
My intention is to remove the values that appear with '...' as shown above and replace with an empty field. The code I’m using to try to remove is this: df['Energy Supply'].str.replace('[.]*', '')…
-
-1
votes1
answer211
viewsDataframe Object has no attribute 'Sort'
I’m trying to create a program to read the data set, sort it by columns and then remove atypical values, but my function is not working because I’m using a new version of numpy 0.25, so the rating…
pythonasked 4 years, 12 months ago vinicius reis 1 -
-1
votes1
answer44
viewsTypeerror at /export_to_xls/ unorderable types: str() < int()
views def export_to_xls(request): obitos = Obito.objects.all() response = HttpResponse(content_type='application/vnd.openxmlformats- officedocument.spreadsheetml.sheet',)…
-
-1
votes1
answer44
viewsHow can I print the screen in the background with Python
I would like to be able to make a screenshot of the application running in the background with Python. On each screen the application enters, I need a print. I managed to, with the pyautogui. But,…
-
-1
votes1
answer28
viewsHow do I know if a list has several equal values?
I am wanting to make a function that returns the equal elements of a list. cartas_jogador_a = ['4', '7', '10', '8', '1', '10'] I wanted to get only the values '10', '10' in another list, already…
pythonasked 3 years, 4 months ago Natan Tavares 1 -
-1
votes2
answers89
viewsWhat is the best way to select a text and how to store it in a variable?
I need to copy a text and I’m using the autopygui. I would like to know how best to select the text and how to store this information in a variable? The solution I have found so far for the first…
-
-1
votes1
answer47
viewsPYTHON error index out of range
There I was trying to create a script that did permutation, create a combination of the list items in a new list. Follow the python code: itens = [] while True: adition = input('Coloque os itens: ')…
-
-1
votes1
answer124
viewsCapture python libpng Warning
I’m trying to treat a huge number of images with opencv python The vast majority will be despised, so I would like to capture the Warning messages from opencv to be able to treat/despise these…
-
-1
votes2
answers34
viewsHow to access an attribute or method from a variable?
I’m getting this mistake: Erro: " 'Series' object has no attribute 'medida' " Is there any way to put a variable in place of the method and Dataframe recognizes the attribute? Below is the code as I…
-
-1
votes1
answer21
viewsHow to pass "invisible" variables from one page to another using a link in Django?
Suppose I have the following code in the.py urls; url(r'^relatorio', views.relatorioView, name='relatorio'), url(r'^relatorio/grafico', views.graph, name='grafico'), On the report page I have a…
-
-1
votes1
answer29
viewspycharm does not recognize mp3 file
Here glr, I was doing the python course in the video course and challenge 21 was to be able to play some mp3 in the pycharm, but when I tried to import an mp3 file it appeared here. someone knows…
-
-1
votes1
answer241
viewsAllow access to the Chrome Filesystem API with Selenium using Python
I need a little help here! I need to set up selenium using the webdrive to click on a Chrome pop-up window. I’ve tried several alternatives I found, but none of them work. A company security policy…
-
-1
votes1
answer213
viewsFlask ajax html communication
I would like a help with a Python application using the Flask framework, I want to send data to html ,and then show this data in a table. the function of flask : @myapp.route('/treino',…
-
-1
votes1
answer30
viewsGet the same value as an Arduino subtraction with Python
The following code on the Arduine yields the value 26. int a = 32760; int b = -32750; void setup() { Serial.begin(9600); } void loop() { Serial.println(b-a); } I would like to send these two values…
pythonasked 3 years, 3 months ago Mateus Guilherme 39 -
-1
votes4
answers405
viewsSearch a specific line in a . txt file and change the content
I have a file containing in each line a CPF number, name and login, separated by comma. Ex: 12345678910, gabriel barbosa, [email protected] 09876543211, carlos silva,…
-
-1
votes1
answer53
viewsWhy when I inform "1.93" gives error when converting to integer?
print('Calculadora de IMC') peso = input('Insira o seu peso (em kg): ') altura = input('Insira sua altura (em metros): ') IMC = int(peso) / int(altura)**2 When I set the height value to "1.93" an…