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
votes1
answer52
viewsPython sequence lists
I have a reference list with repeat values ex:. [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]. I am trying to create another list that creates an increasing sequence from the first set of data, restarting the…
-
2
votes0
answers31
viewsPlotly tree graph showing wrong python values
That boy-girl Sunburst plotly, when used in a dataframe of this spreadsheet, through the code below, generates a graph wrong values of the 'rest' column. For example, in the path…
-
2
votes1
answer56
viewsRounded lines or "Smooth" in Python from an Excel file
I’m trying to make a Python chart on Anaconda’s Jupyter Notebook from an Excel file I created. I put the data and the lines give me peaks in the graph. I wish the lines were more "Smooth" or rounded…
-
2
votes1
answer145
viewsHow to transform an array with strings(list) into an integer array in Python?
I’m new to python programming. I came across today the challenge of picking up a vector (ex:V1== ['MESA 11 22 33 44 ']) in which all its elements are in string format (as if they were one, only…
-
2
votes1
answer129
viewsDiscordpy how to get the name and not the reference to the object
I am playing a little with the library Discord in python, but I got a problem. When I want to get the name of the user who sent the message, and the id and I believe that everything that references…
pythonasked 3 years, 9 months ago Elias Oliveira 178 -
2
votes0
answers16
viewsParamiko does not keep my process running in the background (python)
I have tried an automation where at the end of a looping routine access a server via SSH and open a new process. But in the last part I can’t get the process started, follow the code: from paramiko…
-
2
votes1
answer302
viewsCheck that the string only contains Python letter and space
I want the user to enter their full name, but if they put something other than letters, it should display an alert message. The problem is that the user’s full name requires space between words, and…
-
2
votes3
answers37
viewsSend template data to database
I am facing a problem that in Django, in which my form cannot be validated, therefore, does not enter the data in the database. I want the user to have the option of adding a teacher. The structure…
-
2
votes3
answers112
viewsIn Python how to pass the self between 2 windows using modules
I’m learning Python, version 3.7 with Pyqt5 (Qt Designer) I’m trying to define the value of a label using modules, in window 1 it calls the function and works, but when I open window 2 and click on…
-
2
votes1
answer178
viewsPython with excel (Openpyxl) - take the result of the formula instead of the formula itself
Hey, guys, what’s up? First time around. I have a spreadsheet in excel with several formulas, and I wanted my python code to take for me only the result of these formulas, and not the formula…
-
2
votes1
answer62
views"local" server with python, does not receive an external POST on the same network
I have a server running on Windows 7 PC and am using Pycharm IDE to edit and simulate. This server is receiving information from an ESP32 module that is connected on the same PC network. Sending the…
-
2
votes0
answers65
viewsProblems with python serial communication
So, I’m developing a project for the university, it’s basically the development of a supervisory. I have to read some I/O modules that communicate over an RS485 network. Communication with the main…
-
2
votes1
answer32
viewsReturn the elements of a randomized list
I have an array generated by a string.split(), and the value of this string is obtained by a input. That is to say: string = input("Digite os Nomes separados por Vírgula") arrTeste =…
-
2
votes1
answer60
viewsWhat use is memoryview in Python?
I am reading about arrays in Python and came across a function built in call memoryview. I understood that a difference from lists to arrays is that in the latter it is possible to use the…
-
2
votes4
answers350
viewsHow to add values from a dictionary with arrays by the Python key?
I have the following dictionary: { 'tvmv': [121, 250, 48, 45, 54, 120, 115, 138, 60, 30, 274], 'avic': [358, 60, 40], 'hotels_resorts': [60, 31, 45, 50, 300, 165, 40, 46], 'avani': [70, 40],…
-
2
votes3
answers128
viewsHow to browse a JSON within another JSON in Python?
I wonder how I can walk a JSON within another JSON in Python. In this case, I have a file that is on the following link: https://sisu-api-pcr.apps.mec.gov.br/api/v1/oferta/instituicao/570 And I’m…
-
2
votes2
answers77
viewsIn a Dataframe, modify data from one column conditioned to the value of another column
I am working on an automation with reports for the results of cryptocurrency/stock buying and selling operations. I need to convert the positive value of a cell to negative if it is bought (BUY).…
-
2
votes2
answers82
viewsSort two lists based on the order of the first
Let me give you an example because it’s clearer to explain: x = [7,5,9,4,2,3,8,1,10] y = ['sete', 'cinco', 'nove', 'quatro', 'dois', 'tres', 'oito', 'um', 'seis', 'dez'] I need to sort the list x,…
-
2
votes0
answers31
viewsIs it possible to create private methods for Python classes?
In Rust, it is possible to create a module where some methods associated with a struct are private. I understand that the utility of this is to make available to the end user of the module only the…
-
2
votes1
answer46
viewsalgorithm or reasoning to get close-averaged sets from a list
I have the following list Cu, at 40 values: [1.37812, 1.25154, 1.2486 , 1.22726, 1.22645, 1.16835, 1.14414, 1.1367 , 1.05915, 1.0446 , 1.03972, 1.03597, 0.98309, 0.94804, 0.91199, 0.90972, 0.89231,…
-
2
votes2
answers91
viewsHow do iterators created from lists rescue "random" values in Python?
I’m studying iterators and generators in Python, and I was intrigued by a question, and I can’t find the answer to that anywhere. When we create a Python generator through a generating expression…
-
2
votes3
answers156
viewsHow to join 2 lists in a dictionary?
I want to take 2 lists and turn them into a dictionary, in which each item has as key the i-th item of the first list and as value the i-th item of the second list. I made that code so far:…
pythonasked 3 years, 5 months ago José Marinho 23 -
2
votes4
answers177
viewsInsert names to a list depending on their value
I’m trying to make a draw code, the user inserts the value to be donated and your name. Let’s assume that Bia donates 10 real, Bia’s name has to appear 1 time on the list. And let’s assume that…
-
2
votes1
answer22
viewsPylint on Vscode
I’m starting to use the VSCode to work with Python, and would like to set up the Pylint to highlight|warnings errors while typing (such as PyCharm makes), by default lints are only 'executed' in…
-
2
votes2
answers86
viewsHow to deal cards from a deck using dictionary
I have the following dictionary composed of a list of its values: baralho = { 'Paus': ['Ás',2,3,4,5,6,7,8,9,10,'Dama','Valete','Reis'] , 'Ouros': ['Ás',2,3,4,5,6,7,8,9,10,'Dama','Valete','Reis'] ,…
-
2
votes1
answer33
viewsError in Flask development environment
I created an application in Flask, and can run normally by running only one flask run, but when I spin, it appears that it is in a production environment. When I switch to the development…
-
2
votes1
answer39
viewsLogical error while removing repeated items from a list
I am doing an exercise where I must create a function that removes repeated items from a list and returns this ordered list. My code removes only a few repeated items, but leaves others. I know…
-
1
votes1
answer143
viewsHow to use the Qtreewidget Finditem in Pyqt ?
I have a tree QTreeWidget with several previously included items. I need to search for a string x has the same text value as mine QTreeWidgetItem, or I need to check all items in my tree. Does…
-
1
votes2
answers160
viewsHow to get the IP address from the nmap XML output with a specific "vendor" using Elementtree? in Python
Using the XML output from nmap for reachable virtual machines running on the same host machine - obtained with nmap -oX output.xml -sP 192.168.2.*, would like to get the IP address of each machine…
-
1
votes1
answer250
viewsHow to create separate objects from a loop?
class linha (): def __init__ (self, texto): self.texto = texto def criador (): for i in range(5): a = raw_input ('escreva: ') global objetoi objetoi = linha (a) How do I make the function criador…
-
1
votes3
answers324
viewsPython - NZEC problem in SPOJ (br.spoj.com)
I’m trying to pass a code on the SPOJ (http://br.spoj.com/problems/MITO09/) for solving a very simple problem: Read a matrix, read matrix coordinates, and check whether the same coordinate has been…
-
1
votes1
answer89
viewsNumber inside a file can be the number inside the.Leep team?
Is it possible that a number within a file can be the number of seconds of the.Sleep() team? Example: time.sleep(temp) #código de leitura e salvamento de dados incluído Complete code:…
-
1
votes1
answer1599
viewsHow to get the average sizes of a cluster with Pandas?
Given a Pandas Dataframe, with the data in such a structure: import pandas as pd raw_data = { 'tipo': ['a', 'a', 'b', 'c', 'c', 'c', 'd'], 'ano': [2000, 2000, 2000, 2001, 2001, 2001, 2001], } df =…
-
1
votes1
answer303
viewsif/Else statements and time.Leep()
I have a question. It is possible to put the time.sleep() in a statement if/else? Example: import time if time.sleep(2): print "hello" else: #alguma coisa I searched the internet but found no…
-
1
votes1
answer2056
viewsAnaconda/osx - change the standard python version
I was using python with anaconda in osx 10.8 and Spyder crashed. When I tried to reboot, the launcher showed Spyder as not installed. I imagined that the anaconda might have had some problem and…
-
1
votes1
answer82
viewsHow to get the site’s user list from the Stack Overflow API?
I need to loop the Stack Overflow API to generate data from all forum users, but I don’t know how user ids are generated at the time of registration. Does anyone know how user Ids are generated? Not…
-
1
votes3
answers3271
viewsHow to receive a vector, whose values are separated by spaces
I’m starting in python and use a site that has several problems for resolution, in it the vectors and matrices are passed with the values separated by a space and not comma. For example:v = 1 2 3…
pythonasked 10 years, 4 months ago Lucas Ildefonso 13 -
1
votes1
answer3572
viewsFont size of the caption in a graph made in python
I would like to know how to adjust the font size used in a caption in a graph made in Python using the matplotlib library. I did some research and found this shape. plt.legend(loc='upper left',…
-
1
votes2
answers73
viewsError in Python language
I’m new in Python, is giving this error that exists in the image. http://uploaddeimagens.com.br/imagens/sem_titulo-png--8888 What can I do to fix ?…
-
1
votes1
answer895
viewsRead more than one file tab
My code goes through all cells in my spreadsheet and returns all the values I need, and in this.xls file there is only one tab. Now I have a new file to go through and are 8 tabs. I know I need to…
-
1
votes3
answers222
viewsRemoving characters from a string - Python
Guys, I have the following problem. I have a function that returns me the following output: "Address:58.200.133.200" I would like to save this value in a variable ip, but I only want the part of ip…
-
1
votes1
answer320
viewsPython - Local Multiplayer System
I’m trying to create a local multiplayer system, where will have a script for the "server" and several "clients" can connect. For now I will use in a simple test application, where users will create…
-
1
votes2
answers2221
viewsDynamically change label value
I’m a beginner in Python. How do I change the value of a label dynamically? To be more specific, I have the following code: #!/usr/bin/env python from Tkinter import * import socket, webbrowser root…
-
1
votes1
answer632
viewsPython problem
Hello, I received this problem to solve in python but I do not know much of the language, I know C, but I believe my problem is in reading the problem, I received the program so without any more…
pythonasked 10 years, 4 months ago Vitor Figueredo 209 -
1
votes1
answer492
viewsexec command does not work in python
Well, I’m not able to perform external functions (with exec) that will change global lists to be used in my main function, follows code: m = [] n = [] def mp((a,b),p): c = [n[0] for n in p] d =…
-
1
votes1
answer80
viewsPelican: How to define the layout of each page similar to Jekyll?
I use Jekyll in my website, I’ll stop using for this reason. I wanted to migrate to the Pelican but I’m stuck in layouts. Here’s the problem: In Jekyll I can on each page (page) define the layout,…
-
1
votes1
answer96
viewsProblem attaching value to Python 2 matrix
The problem is in matrix.append([(x+1), vectorY[x][1]]). No matter how much vextor[x][1] is different from (x+1), when added you will receive the same value as (x+1), leaving a matrix with two equal…
-
1
votes1
answer835
viewsError in reading JSON
I am trying to read the Jsons from a folder and get the proper values, I have tested all the Jsons to see if they were valid. The folder with the Jsons is called 'test' for dirname, dirnames,…
-
1
votes1
answer49
viewsHow to use Twisted on Mac OSX?
I’m following a tutorial to use Twisted to establish connection to an app. However, when testing the connection to localhost for testing, it seems that it is not responding. I am using the following…
-
1
votes1
answer89
viewsPython - Convert mysql datatime
I am trying to compare the current date with the date of the last entry of my mysql database: sql2 = "SELECT created_at FROM tempaverage WHERE created_at IN (SELECT max(created_at) FROM…