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
-
-2
votes2
answers29
viewsShow only second field of the field choises
In my model I have an option list and when I display it in the template it appears like this: "("D", "Slow")" and I would like it to be displayed only "("Slow down")". Currently As it should be…
-
-2
votes1
answer32
viewsHow to use 2-d numpy array with interactive panel floatslider for a python image Plot?
Using holloviews and panel. How to create a function that takes as arguments an np.array (2d, an array) and a "value cut". Return the 2d array plotted as image? Being what the argument "value cut"…
-
-2
votes1
answer128
viewsError when an image is loaded into a second Tkinter - Python window
Hello, I’m developing a small program using tkinter, where, in the first window there is a button that opens a second window where there is an image. However, the program does not carry this image,…
-
-2
votes1
answer95
viewsDjango is not saving users in the database
I’m doing a project with Django and using postgresql as a database. I created an app Accounts for user registration, but is not registered in the database and does not appear in the Django admin…
-
-2
votes1
answer41
viewsHow to create an object by requesting data from the user and running from a function?
I created a simple class, I can create an object, but I’m developing a CRUD that needs to create the object from a function. Look at my example: class Funcionario: def __init__(self, nome, cargo,…
-
-2
votes1
answer54
viewsHow to use beatifulsoup to search for a certain word on the page
import requests from bs4 import BeautifulSoup url = "https://www.nike.com.br/Snkrs/Produto/Dunk-High-SP/153-169-211-279300" req = requests.get(url) html = req.text soup = BeautifulSoup(html,…
-
-2
votes1
answer379
viewsError trying to install packages on Linux using Pip command [Linux]
I cannot install packages using Pip on linux, this is the error screen: Collecting pygame Using cached pygame-1.9.6.tar.gz (3.2 MB) ERROR: Command errored out with exit status 1: command:…
-
-2
votes1
answer89
viewsOnly she needs to calculate the result of this formula for various values of x
(x**2 - 4*x + 5). Only it needs to calculate the result of this formula for several values of x. Input format: Two integers, one in each row: The first number (a) represents the first value of x to…
-
-2
votes3
answers82
viewsHow do I differentiate an int and float value for my program
Guys...so new in Python and wanted a help, I am making a calculator and I used the function isdigit() to avoid the error of the person putting a non-numeric character, however it recognizes only…
pythonasked 4 years, 1 month ago Logan Carvalho 17 -
-2
votes2
answers392
viewsconcatenate python csv files
3 lists that form the directory and the file name, I want to concatenate the files "lists_tipos_anos.csv" (around 44 files) in "lists_tipos_all.csv" (generate 4 files), where the "all" is all the…
-
-2
votes1
answer54
viewsTrying to access a value inside a dictionary in Python, but I get an error when printing run the code
I was creating a dictionary playing with python Pokemon in pycharm Comunity, but when I went to perform the dictionary access, I was returned an error message in the code when trying to print one of…
-
-2
votes2
answers114
viewsMost efficient algorithm to find indices of the 2 elements of a list whose sum is equal to a certain value
The Challenge is simple, find two numbers from a given list that if summed result in a specific number and return the index of those numbers. That I solved, the problem is that in addition the…
-
-2
votes1
answer38
viewsUse a 30 x 3 array using class, def, parameters - Python
The intention here is to use a matrix capable of storing in each position all the information related to a given service (number, value, service code, customer code). Each row represents one day of…
-
-2
votes1
answer119
viewsWhy am I getting this error "Operationalerror at /admin/core/comment"?
When I try to access the Commnets field in my admin area I get this error. Why? OperationalError at /admin/core/comment/ no such column: core_comment.content Request Method: GET Request URL:…
-
-2
votes1
answer62
viewsPython cs50, what happened with this simple code
Good morning, I’m starting a Python course by Cs50, but I don’t understand what happened to the code I wrote. name = input("Name: ") print("Hello, " + name) You can see that it is simple and yet…
-
-2
votes1
answer60
viewsImage reference path in Label Tkinter
I’m training POO in a personal project that I’m developing in showing a window called by a button that shows "samples" of text from a language, showing a flag and text from that language. The…
-
-2
votes1
answer197
viewsNumeric types to Aggregate error
I’m making a program based on a file .csv, but when I run the program the error occurs No numeric types to aggregate. File part: datatime,app version,gender,money 02/09/2019,4,F,$7.43…
-
-2
votes1
answer192
viewsPython Api Data Filtering
I’m doing an algorithm on Python that makes a get in a url to dollar quotation, but the return of that get has a lot of unnecessary information I would like to know how to filter this data follows…
-
-2
votes1
answer95
viewsHow to browse a dictionary within a python list?
I have the following JSON: { "Aeroportos": [ { "Continente": "Europa", "País": "Grécia", "Localização": "Atenas", "Nome": "Aeroporto Internacional Eleftherios Venizelos - Atenas, Grécia (ATH)",…
-
-2
votes1
answer244
viewsParallel scripts using Threading - Python
I’m trying to run parallel scripts in Python, using the threading library, but I’m not being able to apply it to my case. I believe the problem is to receive my function, but even creating a list,…
-
-2
votes1
answer24
viewsPerform the next step without going through a previous one
I have the following problem, if the user does not type either’S' or 'N' will return the error message I treated, however it will continue the loop, but I wanted a way not to ask again to type the…
-
-2
votes1
answer122
viewsA function that takes the names of two files as arguments
Program containing a function that takes the names of two files as arguments. The first file contains student names and the second file contains student grades. In the first file, each line…
-
-2
votes2
answers101
viewsDoubt print game list of old Python
I’m developing the old game, which is still in the beginning. I’m having trouble trying to print the first line of the list. When I print the list, it’s always empty. There could be two mistakes: or…
-
-2
votes1
answer48
viewsHow do I resolve this "Valueerror" in Python 3?
I’m having trouble solving this error: Valueerror: Too Many values to unpack (expected 3) This is my code: def func(array, n): m = len(array) soma = 0 saldo = [] res = 0 bool = False saldo = [0 for…
pythonasked 3 years, 10 months ago Pedro Henrique 3 -
-2
votes1
answer27
viewsHow to use the information of a text field in qml in a py file
Next, I have 2 Qml files, the first has multiple text Fields that I want to extract the contents and allocate in a python variable then work with this variable in an algorithm and then export the…
pythonasked 3 years, 10 months ago Dayvid Borges 1 -
-2
votes1
answer147
viewsTurn a list into a python pandas csv
I have the following code that scraps data from an auction site: lista = [] for pagina in range(1,34): url =…
-
-2
votes1
answer32
viewsWhere should the program modules be located?
I developed a personal agenda on Python using the Sqlalchemy and the Pyqt5. I realized that, for example: I have the main.py aquivo app = QtWidgets.QApplication([]) login = TelaLogin() if…
-
-2
votes2
answers80
viewsWhy am I getting these errors: Typeerror: Object type <class 'str'> cannot be passed to C code
I found a code github link to code: https://gist.github.com/shinyquagsire23/0d6a5119ee7fb40de2fcfb9088168d63 but when I try to execute the code I get these messages: currently I have no knowledge in…
pythonasked 3 years, 9 months ago Kelison Bessa 29 -
-2
votes1
answer495
viewsAttributeerror: 'numpy.ndarray' Object has no attribute 'append'
The program below serves to calculate two matrices (w1 and w2) and, from them, calculate an f rmula (called transmission matrix) and after that take the results of this matrix and trace the…
-
-2
votes1
answer82
viewsHow to pass multiple files with click python?
I have a directory with several files: arquivo.txt arquivo1.txt arquivo2.txt... And I have this code: import click @click.command() @click.argument("file", type=click.File('r')) def cat(file):…
-
-2
votes1
answer81
viewsI would like to count a list of words in a.txt file using python
I have this code that counts the number of occurrences of a string in a.txt file and returns it to me. But I would like to use a list of items or an array. And that he would return to me the…
-
-2
votes2
answers88
viewsDjango/Python primary key generator with low collision risk and good performance
GENERATING UNIQUE PRIMARY APPLICATION KEYS I would like to get tips on how to generate primary keys with low risk of collision and that do not reduce the performance of Postgresql operations.…
-
-2
votes1
answer54
viewsHow to pass the value of Sg. Input to a variable in another part of the code?
I’m doing a program to present in the college project, but I’m doing it through the window method by pySimpleGUI, I wanted when the person typed in Sg. Input a quantity, that quantity was calculated…
-
-2
votes2
answers47
viewsI need the highest and lowest note of the matrix, but when I print out a vector with the three notes what do I do? I’m using min and max
def mostrandomatriz(): for l in range(0,5): #estética print(f"Aluno {l+1}") print("|-----|") #leitura da coluna e impressão da matriz for c in range(0,3): print(f"|{matriz[l][c]:^5}|") #estética…
pythonasked 3 years, 8 months ago Monkey Martins 1 -
-2
votes1
answer132
viewsPandas error 302; read_html()
I need to import a table that is in html using pandas, but when trying to do this the same returns me error. import pandas as pd url =…
-
-2
votes1
answer126
viewsHow do I filter queries from my database by Python? Using mysql
I am making a system of "inventory", in it we have in the second screen a search screen and the third the screen that shows the results of the search. This search is a database search, but for now…
-
-2
votes1
answer80
viewsSelenium - Click Input with Onclick() event does not work
I’m having trouble trying to click a button (Input) HTML with Selenium on Internet Explore. When executing the command click() nothing happens nor even errors are presented. Follows below the layout…
-
-2
votes1
answer48
viewsHost issues when connecting two computers with socket-py
Hello! I’ve been trying to learn about python socket. My first code would be a program to connect a client to a server and then send data. I put the python file on the server side on another…
pythonasked 3 years, 8 months ago Thunder - 41 1 -
-2
votes3
answers72
viewsHow to manipulate cells from a vector?
I created a program that fills a 10-position vector with random numbers between 0 and 20. Now I need to show a new manipulated vector, where each cell is the sum of itself and the previous cells.…
-
-2
votes1
answer74
viewsPython, how to invert a chained list?
Hello, I need to create a function that receives an unordered list in the structure of nodes and it should reverse the order of the elements of that list, I tried to make a L[::-1] to reverse the…
-
-2
votes1
answer1591
viewsDicionario Python
Can anyone help me? I’m having a hard time doing this exercise. Consider the following data set: Name + (N1, N2, N3, N4). Name represents the name of a student and should be used as key. N1, N2, N3,…
-
-2
votes1
answer30
viewsIn a df, how to select items in column with datetime format, classify them into periods (morning, afternoon and evening) and place them in a new column
Hello!!! I am looking for help to solve the problem below. My df has a ' DATA column with format 29/01/2019 17:50:11), which by default is converted to 'object' type pandas. All in all, it has 640…
-
-2
votes1
answer65
viewsHow to capture data-tooltip using Selenium in Python
Hello, is the following my problem: I am making a web scraping in the following URL > https://www.maze.com.br/produto/tenis-nike-air-jordan-ma2-ultramarine-branco/4749595. I came across a slight…
-
-2
votes1
answer44
viewsBy importing a given CSV into the notebook jupyter and turning a variable to 0 and 1 hour to show the table again this as Nan
import pandas as pd Train = pd.read_csv('database') Train.head() #Map sex and shape to 0 and 1 Train['Sex_num']= Train.Sex.map({'Female':0, 'Male':1}) #compare using the Loc function to locate the…
pythonasked 3 years, 8 months ago Lucas Gonçalves e Silva 1 -
-2
votes1
answer28
viewsYou’re not saving the picture on the way
I’m creating a field of ImageField no Jango, but when I put to save, it saves in the bank the name of the image but does not save the path to the image. models: class Cliente(models.Model): photo =…
-
-2
votes1
answer46
viewsi am not managing to inherit the client class with one of the two
i create a client that will be Pfísica as I do for class Pfisica inherit from class client. class Cliente: def __init__(self,*lista,**D): self.codigo = D.pop('cod','--') self.nome = D.pop('n','--')…
-
-2
votes2
answers137
viewsA proposed infinity loop PYTHON exercise
HELLO, I’m trying to resolve the issue below, but I can’t make the LOOP work, since the exercise asks that even after choosing a type of average, the instruction comes back asking infinitely the…
-
-2
votes1
answer98
viewsHow do I inform pro python that an excel cell is blank
I need to inform python that if the cell "Relation" is in WHITE, it jumps to the next page and if it is filled it fills with the cell content. The code is working normally when the cell is filled,…
-
-2
votes1
answer56
viewsInsert edge into graph
I’m trying to insert an edge into a graph. The problem is to represent a metro line, considering the existing information in csv files. I created the classes Vertex, Edge, Station(Vertex),…
-
-2
votes1
answer45
viewsDriver name not set
I’m doing this bot to access instagram, but is presenting an error that I can not identify. I’m a beginner and I’m having trouble finding the error. If anyone can help me, I appreciate!! from…