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
votes1
answer869
viewsIn pandas and unidecode, how to avoid warning messages - copy of a Slice from a Dataframe?
In Python3 and pandas I am reading CSV files to create dataframes. In some columns I need to remove the accent (English). I do it with unity But in some files appears a warning message import pandas…
-
0
votes2
answers293
viewsHow do I display if I can ping a machine without displaying the textual ping pollution itself?
My code is printing ping output (that polluted screen), but I wanted to print only the default "{ip} ta on". How you currently print: PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data. 64 bytes…
pythonasked 6 years, 8 months ago Joao Vitor 11 -
0
votes1
answer198
viewsPython asynchronous generators
With the introduction of the library asyncio, a new syntax was introduced to define coroutines in Python >= 3.5 and with it it it is possible to define asynchronous methods, asynchronous…
-
0
votes1
answer345
viewsInstalling Django with Python3
I received a project to be done only with Python in v.3.4+ and I’m not getting Django to work in versions other than 2.7. Does anyone know a link that teaches the entire installation of Django in…
-
0
votes2
answers514
viewsHow to have two counters in the same loop?
I have the following structure in my code: for c in range(0, len(str(ListaTemp[4]))): for c2 in range(c+1, len(str(ListaTemp[4]))): if str(num)[c] == str(num)[c2]: valido = True And so. My teacher…
-
0
votes1
answer429
viewsPyserial library problem (PYTHON)
I am trying to control Arduino by a Python script through the "pyserial" and "serial" library. But every time I run the code it misses the first few lines: import serial ser = serial.Serial('COM7',…
-
0
votes1
answer896
viewsRead pairs of integer values using python tuples
I am new here, as well as in Python. This question I am presenting to you, is related to a question of college work. I have tried in every way to resolve and could not. I am here out of desperation.…
pythonasked 6 years, 8 months ago Aline Ferreira 3 -
0
votes1
answer49
viewsCheck the relation of two objects in a list
I need to extract from a pure text the full value of an agreement. I have hundreds of documents with some figures, and I realized that generally the highest value is also the total value of the…
-
0
votes3
answers5999
viewsInserted in a list of lists in python
I would like to fill in a list where each position of the same was a list. lista = [[], [], []] have an input: 44 45 49 70 27 73 92 97 95 and I would like to list the numbers so that the Index is…
-
0
votes2
answers4270
viewsFilter lines in pandas by a list
Given the dataframe below, I would like to filter the data of the lines according to the list 'listFilter'. nome valor 0 foo 2 1 bar 3 2 fiz 2 3 zaz 5 4 foo 6 5 far 7 6 bar 2 7 fiz 9 8 zoo 6 9 boo 3…
-
0
votes2
answers402
viewsStrings in python
I know the basics of coding strings in Python, but I still cannot go forward and complete the whole requirement of the statement. I don’t know how to encode the quantities you require in the…
-
0
votes1
answer1666
viewsIf/Else condition in a column (python)
I need to build an if/Else in a column in the table [6]. Follow the result print (without if/Else applied): Follows the code: import requests import pandas as pd from bs4 import BeautifulSoup…
pythonasked 6 years, 8 months ago Erick Kill 5 -
0
votes2
answers2615
viewsPassword Validation with Python
I have the following requirement to validate a password in the register: Size: 10 characters Capital letters: 2 Lower case: 2 Number: 1 Symbol: 2 How do I check with python? So far I’ve only been…
-
0
votes2
answers107
viewsPython exercise
Hi, I have python as one of my second semester classes and I need a little help. I have an exercise where I can’t make it work properly; here is the statement:"Write a program that reads a set of…
-
0
votes1
answer64
viewsPython, Game of Life Implementation
I noticed that there is already a question related to this issue, but my implementation will be different. The code I have at the moment is as follows:: import sys, pygame pygame.init() size =…
-
0
votes2
answers106
viewsHow to separate similar images (Pyhton / Machine learning)
Objective: To separate images with the same characteristics of a folder with several images (Exp: photo1, photo2, photo3, photo4, photo5 >>> photo1.Copo1 photo2.Copo2 photo3.Copo3;…
-
0
votes1
answer70
viewsKnow the smallest number with Function min()
I want to know the smallest number of this list, which I present below the code. I don’t know where I’m going wrong, I think I need to convert the list. Example: lista=[1, 3, 5] def min(values):…
-
0
votes1
answer35
viewsgeneration of a vector through algebraic operation
I have a vector "tensao" with about 30 values inside, to generate a new vector "defo_calculada2" need to add 0.2 in each value of the vector "tensao", I believe it has a correct way to flow this sum…
pythonasked 6 years, 5 months ago Fabio Dal Zotto 11 -
0
votes1
answer624
viewsExercise in the ordering of tuples
I’m getting beat up in a Python exercise. He asks for the following: Create a function that: Receive a list of tuples (data), an integer (key, zero by default equal) and a boolean (reverse, false by…
-
0
votes2
answers444
viewsHow do I assign the last value of an array to a variable?
I need to put in a variable the last value of a vector, problem is that this vector can vary in size. Is there any direct function that brings the last vector value? I tried to use a variable to…
pythonasked 6 years, 5 months ago Fabio Dal Zotto 11 -
0
votes1
answer194
viewsLow text resolution in Python Kivy
I’m starting in Python and Kivy, but I’m not understanding why the generated objects are so low-resolution. In a simple screen of username and password, one can observe the serrated text, ie with…
-
0
votes2
answers720
viewsPython 3 and Tkinter: progress bar does not update during script execution
Hello. I am creating a layout converter using Python 3.6.4 and Tkinter. Among other things the GUI must have a progress bar that updates its value with each interaction of the conversion process,…
-
0
votes2
answers589
viewsLatex and Python or R integration
Hi, I have a project that involves reporting automation. Currently all reports are done through word and graphics in excel, now I’m trying to implententar an application that generates graphics…
-
0
votes0
answers138
viewsUbuntu - error trying to update packages
I am trying to update the packages and is giving the following error when trying to update sudo apt-get upgrade Lendo listas de pacotes... Pronto Construindo árvore de dependências Lendo informação…
-
0
votes1
answer271
viewsHow to write CSV file data without erasing existing data
I need to save data in CSV file without it deletes the existing data in the file, just create a new line with the informed data material=str(input('Informe o material: '))…
pythonasked 6 years, 5 months ago Fabio Dal Zotto 11 -
0
votes0
answers1141
viewsHow to read . csv file and use as a list in Python
I need Python to read a CSV file and use the data in it as a list. example of CSV data francisco, carlos, melo, luis, claudia, and I need that after reading Python use this data as this list below:…
-
0
votes1
answer447
viewsHow to copy files preserving their metadata?
I am making a script that identifies the changed files in two folders and then copies (if changed on modification date) from one to another, synchronization. To copy the files already tried to use:…
pythonasked 6 years, 4 months ago marciomendonsa 11 -
0
votes1
answer327
viewsDisplay manytomany on list_display on Django
I am trying to display some items in manytomany in the list display on Jango, but it is returning an error, follow the codes: Models py. class Apenso(models.Model): usuario = models.ForeignKey(User,…
-
0
votes0
answers933
viewsProblems with openpyxl. Open Excel File with Python
I am trying to read an Excel file but it appears this error message. Warning (from warnings module): File…
-
0
votes2
answers375
viewsExport process information to a . txt - Python
Good morning! I have a problem exporting the information that my process is generating. Currently I copy everything in mine print and paste it into a txt file, but I’d like to take this manual…
-
0
votes1
answer310
viewsOutput print is not showing
I typed exactly that: import math num = float(input('Digite um numero: ')) print('A parte inteira do numero {} é {}.'.format(num, math.trunc(num))) However, when executing, only this appears: Digite…
-
0
votes1
answer2052
viewsHow to create a local network (intranet) with Django?
I’m racking my brain, I’ve tried several and several tutorials gringos and nothing works with excellence. I have a system made in Django on a common computer (windows 10) and I’m trying to leave the…
-
0
votes1
answer82
viewsHow to click a checkbox when another obscure element is it?
I’m writing a code to automate some processes on the SIAFI site, I couldn’t get Python to click on a checkbox, except by importing the package pynput and using the mouse positioning function with…
-
0
votes1
answer1421
viewsLine Breaking in txt file - Python
I am with a file selects the main words cited in the code I prepared. Put it in my file .txt it loses the line breaking that would be the most important for this document. Code: f =…
-
0
votes1
answer153
viewsRedirect Http to Https - Nginx with Let’s Encrypt
At the moment, the domino https://meudominio.com is working, but I can’t redirect http for https using the Let’s Encrypt. I’m following this tutorial: Link Below is my configuration: server { listen…
-
0
votes1
answer294
viewsBubble Sort in Python3
def bubble_sort(list): for i in range(len(list)): for j in range(len(list)-1): if list[j] > list[j+1]: list[j], list[j+1] = list[j+1], list[j] else: continue I just made this Bubble Sort, but I…
-
0
votes0
answers67
viewsIs the SSL Direct Request Text CONNECT or GET? (Python + Socket + SSL)
# -*- coding: utf-8 -*- import socket, ssl, threading, select def conecta(c, a): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(('123.456.789.123', 444)) s = ssl.wrap_socket(s,…
-
0
votes1
answer272
viewsError creating column in Pandas dataset
Hello, I am creating a project in python using Pandas and I want to create a column whose values are the column Closed - Open, but there is an error that I cannot solve. My code: import pandas as pd…
-
0
votes1
answer44
viewsImporting Module Within Module Python3
There are the following folders: └── Programa/ ├── main.py <----- Inicio esse... ├── bin/ | └── config.py <----- esse importa o db.py └── database/ ├── __init__.py └── db.py On the console…
-
0
votes1
answer130
viewsInfinite wait per server response using python sockets
I am trying to send a message to a server API in order to get a response. I am using the following code: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address =…
-
0
votes3
answers347
viewsImport csv as float
I am with the following problem, I am importing a basis for python, however I can not manipulate it (make average), by the same as str, I need to import it all values come as float.…
-
0
votes3
answers1219
viewsWhat is wrong with the Python code?? Bhaskara
import math def Bhaskara(): a = int(input('Digite um valor para A ')) b = int(input('Digite um valor para B ')) c = int(input('Digute um valor para C ')) #(-b +- {-b² - 4 * a * c} ) / 2 * c operacao…
-
0
votes1
answer146
viewsSerial Communication and Array Division with Comma
Hello, Good Night, today I came up with another problem, reading data generated by sensors of the Arduino, I was able to print them and save them in an array, but to really get good, I need to break…
-
0
votes1
answer325
viewsFunction running without clicking the Python button
Good night, My callbackInsereCritico function runs straight without the click of the button, which may be? def callbackInsereCritico(nome): conn = psycopg2.connect(host='localhost',…
pythonasked 6 years, 8 months ago Állan Coinaski 141 -
0
votes1
answer66
viewsimporting a file containing a function I wrote: no global variable
Constroimatriz.py file: """ Escreva uma função que recebe um inteiro m e outro n e com isso constrói uma matriz mxn """ matrix = [] def main(): m = int(input("Digite o número de linhas da matriz:…
-
0
votes1
answer202
viewsScreen printed products in Tkinter-Python
I’m having trouble getting back to one screen without creating another... I couldn’t get her to come back to the same screen I created. I wonder if I could use the .destroy()? Follow the code below:…
-
0
votes3
answers353
viewsHow to create a accumulator
I have a few classes I want to display number of approved students. What I’ve already done nota= a if nota >= 60 and nota < 100: else: Exit approved 20 failed 50, but I have seventy students.…
pythonasked 6 years, 4 months ago Lucas de castro 1 -
0
votes3
answers191
viewsHow to create a dictionary with a word and its adjacent from a string?
I have the following string: texto = "We are not what we should be We are not what we need to be But at least we are not what we used to be" This would be the return I wanted: for every word…
-
0
votes1
answer914
viewsUse return of one method in another method of the same class
I am working with The Guardian API, through two methods, search_content() and data_to_csv(), contained in the Theguardian class. The first method is responsible for searching The Guardian database…
-
0
votes1
answer264
viewsREGEX to remove websites, emails
I want to remove website addresses, emails, etc... url_regex = re.compile(r'(?i)(<|\[)?(https?|www)?(.*)?\.(.*){2,4}') mail_regex = re.compile(r'(?i)(<|\[)?@(.*)\.(.*){2,3}') This way I could…