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
answer619
viewsBatch File to access multiple directories and run python script in different command prompts
Hello everybody all right? I’m trying to create a bat file to run python scripts in different directories, something like that: C:\Test | --- Test1\example.py | --- Test2\example.py | ---…
-
0
votes2
answers1038
viewsPython - creating table
I have two variables (coordinates X,Y) that I am taking this information from a table . plt, I would like to save them in another table. I’d like the table to look like this X Y 10 48 10 50 20 30 I…
-
0
votes1
answer712
viewsPython Glossary, library synonymous with package? Module synonymous with class?
I’m studying Python with video lessons, and the teachers use many synonyms that seem the same to me. In the case of these two terms are the same thing? Module by what I found right here would be…
-
0
votes1
answer41
viewsDjango REST Swagger - Gera 2 GET methods
I am implementing a REST API with Django REST Swagger 2.2.0. For a given endpoint I have defined that the following methods are available: http_method_names = ['post', 'put', 'get'] However, in…
-
0
votes2
answers228
viewsAllow a list as argument
I have a Python REST API that takes 2 arguments, a Url list and a word. I am a beginner in Python and would like to know if it is possible to split the string of the URL to accept more than one URL…
-
0
votes1
answer21
viewsHow do I pass data between apps on the same network?
I plan to make a custom application to help in the automation of some jobs on the computer, but it needs to run the commands on the mobile. The application part itself in no problem at all, but I…
-
0
votes0
answers45
viewsError due to update in Python
I am developing an install.py file that will serve as an alternative to install and create executable qq program in a simple and easy way. I’m having difficulty in the update function, I get to…
-
0
votes1
answer634
viewsPython - Keyerror
Someone can help me ! I am reading a csv file and then I do an INSERT in Mysql database, but I get the following error Keyerror: 'id' I have checked the CSV file several times, the file has all the…
-
0
votes2
answers253
viewsK-Means Algorithm
Good morning, I will apply the K-Means in a given dataset, I already executed normal for fully numerical dataset, ex: Iris( vesicolor, setosa, virginica), but I came across a dataset with…
-
0
votes1
answer96
viewsUnify two or more variaves with jupyter notebook
Good afternoon! I have a database with the variables: number card, date of hospitalization and date of discharge. I want to unify the three variables in a single with the name Chave_hospitalization.…
pythonasked 5 years, 7 months ago Cosme Franco 15 -
0
votes1
answer227
viewsMap dynamically generated tables in Django by another application
I will develop an application with Django in which it will be necessary to query data in a database that is powered by an ERP (desktop). This ERP generates some drive tables by adding at the end of…
-
0
votes1
answer114
viewsHow do I make pdfkit ignore extensions?
I have the following code import pdfkit options = { 'page-size': 'Letter', 'margin-top': '0.75in', 'margin-right': '0.75in', 'margin-bottom': '0.75in', 'margin-left': '0.75in', 'encoding': "UTF-8",…
-
0
votes1
answer204
viewsUse of Class in Kivy
Good afternoon, I want to make a program that uses several combobox and in one window. But I can’t get both. When I run the program, only one of the combobox appears. Below I send the current code.…
-
0
votes2
answers57
viewsProblem with list creation
I’m trying to create a function that has as input a list. The function calculates the number of characters of each component of the list and returns another list of numbers. After that would have to…
-
0
votes1
answer1061
viewsHow to use the title() method in Python?
How do I use the title() in Python in a list, tuple, set? Exemplos que não executam: lista = ['banana', 'mamão', 'maçã'] print (lista.title()) tupla = ('banana', 'mamão', 'maçã') print…
pythonasked 5 years, 7 months ago user141036 -
0
votes2
answers206
viewsSplit Double Python Array
I need to get coordenadas cartesianas and separate them so that you know what the ordered pair is. I receive a string where the dots come this way: x0,y0 x1,y1 ... xn,yn I used a array split by…
-
0
votes1
answer548
viewsVariable check if the field is not typed in Python?
I need to check if the variable was filled with a name, I tried to check with If and break but the field keeps filling without typing any word.... Below is the code I’m making... opcao = 0 while…
pythonasked 6 years, 1 month ago Maycon Willian Alves da Silva 75 -
0
votes1
answer125
viewsHelp with Python function
I am currently "developing" a software in python and I have a question about how I can optimize it. My question is the following, I have to calculate grades according to age and rates, Example: One…
pythonasked 5 years, 7 months ago Alysson Drews 11 -
0
votes1
answer168
viewsHow to update some elements in SET in Python?
Not all the elements I want to update on SET only the country needs to be changed France to Germany My code is like this: paises = {'França', 'Japão', 'China', 'Brasil', 'Espanha', 'USA', 'China',…
pythonasked 5 years, 7 months ago user141036 -
0
votes0
answers59
viewsI want to be able to access system folders
I am doing a ransomware for a college job (will run on Vms) and I would like to target a folder the folder "System32" to "kill" the VM, but I need "power" and I don’t know how to do it The course is…
-
0
votes1
answer92
viewsHow to make more than one type of request to the Python server?
I separated using a function, but the code does not receive the 'date'. COMPLETE SERVER CODE: import socket import json import sys dicty = { 'the': 'o, a, os, as', 'hello': 'ola', 'hi': 'oi',…
-
0
votes1
answer37
viewsIoerror: [Errno socket error] [Errno 8] _ssl. c:504: EOF occurred in Violation of Protocol
Hello, I am running a simple python code (2.7.3) to launch a webhook message on Discord and am encountering the following error: urlopen(url).read() File "C:\Python27\lib\urllib.py", line 86, in…
pythonasked 6 years, 1 month ago Lucas Silva 3 -
0
votes2
answers42
viewsIf a function is too long, is it recommended to divide it into smaller ones?
I have the following function, which I intend to extend: def get_dataframe(site, search): if site == 'pichau': try: soup = get_page(f'https://www.pchau.com.br/catalogsearch/result/?q={search}')…
-
0
votes1
answer528
viewsCalling a Python function that is already running
I have the following scenario. I have a function that consumes a lot of RAM and I would like to let it run in the background for every time I call her not to have to reload all the data in memory,…
-
0
votes1
answer45
viewsTurn dataframe column into hours, minutes and seconds
I’m having trouble turning a numeric integer column that is in seconds to the format of hours:minutes:seconds , for example: df = pd.DataFrame(np.random.randint(900,4000,size=(10000, 1)),…
pythonasked 5 years, 7 months ago NickSantiago 3 -
0
votes3
answers703
viewsHow to leave the program open in python
I made a program that reads a file but it reads and already closes, how to add a 'Press S to exit' for example and leave the print on the screen for longer? -below is the code…
-
0
votes2
answers79
viewsCommand imread() and iteration
I’d like to make a loop with that command: imagem = cv2.imread("imagens/0.jpg",0) imagem = cv2.imread("imagens/1.jpg",0) imagem = cv2.imread("imagens/2.jpg",0) imagem = cv2.imread("imagens/3.jpg",0)…
-
0
votes2
answers32
viewsProgram performance in order of module loading
Someone would tell me if there is a relevant difference in the performance of a program (in this case, done in Python) when importing all modules to be used from the beginning of the code instead of…
-
0
votes2
answers80
viewsexec with n does not work
I’m trying to use the function exec in a code that has \n, but it seems that this function does not support \n a = ''' open('test.txt', 'a').write('Hello, world\n') ''' exec(a) Error: SyntaxError:…
-
0
votes2
answers3058
viewsHow to use a Python Break?
Good afternoon, I am doing a job for the college on conversion, I have this code below and I wanted to use a break in it so when the user type a number q not be the '1' or '0' he of a msg and return…
pythonasked 5 years, 6 months ago Anderson Santana 13 -
0
votes1
answer397
viewscv2.error: Opencv(4.1.0)
Code below: import cv2 imagemCarregada = cv2.imread("exemplo.jpg", 0) cv2.imshow("imagem", imagemCarregada) cv2.waitKey(0) cv2.destroyAllWindows() Error presented:…
-
0
votes1
answer172
viewsCreate a program that receives a line of text and counts the vowels showing the respective Histogram
exercico: Prepare a program that receives a line of text and counts the vowels showing the respective Histogram a in the following form: Example: Last line of text: "Next fourth line of text is…
pythonasked 6 years, 1 month ago Matheus Andrade 205 -
0
votes0
answers3830
viewsThe syntax of the file name, directory name or volume label is incorrect
I’m not able to solve this problem that says: "The syntax of the file name, directory name or volume label is incorrect". I imagined it was a poorly specified path, but I guess it’s not. import…
-
0
votes1
answer285
viewsMask using flask does not load
This is the header: <script src="{{ url_for('static', filename='jquery-2.1.4.min.js') }}"></script> <script src="{{ url_for('static', filename='main.js')…
-
0
votes1
answer122
viewsWhen I run code outside of IDLE (PYTHON 3.7) the created Tkinter window does not appear
I’m beginner and was studying Tkinter and developed this code, within IDLE it works perfectly, but with advancing I turned it into executable but does not rotate, even inside the cmd does not…
-
0
votes1
answer202
viewsUnicodedecorror when reading CSV file
I am trying to read a CSV file in Python using: import csv import json arquivo = open('dados_teste.csv', encoding='utf8') texto = arquivo.read() resultado = json.loads(texto) print (resultado) But…
-
0
votes4
answers2571
viewsNumber of vowels in the Python function
I want to do a function in Python that makes a count of how many vowels there are in a string in which the user type. My code: def cacavogais(): i = 0 j = 0 string = str (input("Digite alguma coisa:…
-
0
votes2
answers176
viewsChrome bot error - ERROR:platform_sensor_reader_win.cc
I have a python application that performs some repetitive tasks for me by opening Chrome and using it as a bot (I cannot be making the code available because I work under a confidentiality…
-
0
votes3
answers693
viewsI can’t make the sum of the first 100 prime numbers, where am I wrong?
#python3.7 cont = 0 cont_100 = 0 primos = 0 num = 1 soma = 0 while True: primos += 1 while primos != num: if primos % num == 0: num += 1 cont += 1 if cont == 2: soma += primos num = 1 cont_100 += 1…
-
0
votes1
answer75
viewsError executing "module" code
When performing an exercise on module, the following "Typeerror: not all Arguments converted During string formatting,"happens? #coding: utf-8 num = input("Digite um número: ") if(num % 2 ==0):…
pythonasked 5 years, 6 months ago Raul Nascimento 103 -
0
votes1
answer737
viewsPlot function in PYTHON or MATLAB
People need to plot a function and I can not find cool tools for it, because the function has by definition constant, and I thought to use a programming language for this, but I do not know python ,…
-
0
votes2
answers309
viewsGet python Documents directory automatically
I need to automatically get the address of the document folder of any Windows with Python. Currently in my script determined as shown in the variable main_folder, but whenever I change PC I have to…
pythonasked 6 years, 1 month ago Edeson Bizerril 661 -
0
votes2
answers250
viewsJoin two matrices and display them in a third vertically
I created two M1 and M2 matrices and they have a dimension for seven elements. A third matrix called M3 has two dimensions where its first column must be formed by the elements of matrix MA and the…
-
0
votes1
answer41
viewsExecution error on library startup
import sys import tkinter counter = 0 def update(): global count, b counter += 1 b.config(text = "click cont = " + str(count)) print("updating") root = tkinter.Tk() b = tkinter.Button(root)…
pythonasked 5 years, 6 months ago Enzo Carvalho 11 -
0
votes1
answer136
viewsRead XML and Print Data in Word or PDF with Python
Good afternoon, gentlemen. I would like to request the help of university students to read this XML file below and print the values in Word or PDF. <?xml version="1.0" encoding="UTF-8"?>…
-
0
votes1
answer295
viewsOrdinal numbers
Hello, I’m starting programming and I’m studying Python. Performing an exercise I managed to get the expected result. However, when I try to do the same program by converting the list to INT, it…
-
0
votes1
answer220
viewsSelect column item in Python
I was able to filter the items I want, but they are in a kind of column. I did it that way: import os cmd = os.popen('arping -I enp1s0 -c 2 192.168.0.1') arr = cmd.read().split('\n') for line in…
-
0
votes2
answers62
viewsComparison of lowest value in list
My problem seems to be simple but it’s bugging my head kkk, there it goes: When I compare my Values list to find the lowest value, it always returns 0, what happens sera? Follow Cód below. Obs:…
-
0
votes1
answer172
viewsHow do I pass values from a CSV to a JSON in Python?
I tried two ways to read a CSV file and pass the values in the JSON value parameter, but it does not return any result, if I pass the direct values, it works. Code 1: import boto3 from datetime…
-
0
votes4
answers2181
viewsCheck file extensions in Python
I need to check the extensions of all files inside a folder, for example: Pasta: arquivo1.txt arquivo2.wav arquivo3.mp3 arquivo4.mp3 arquivo5.mp3 arquivo6.txt output: txt, wav, mp3 Does anyone know…