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
votes1
answer535
viewsAccess functions within classes in kivy + python
This is the file . py class Tela(): pass class teste(): def chama(self): pass def save_d(self): pass class Prg(App): def build(self): return Tela() Prg().run() This is the file . Kv <Tela>:…
-
1
votes1
answer542
viewsMultiprocessing in Python
I’m creating processes using multiprocessing in Python, but need to create processes within other processes, ie child processes. It is possible to do this using multiprocessing? Code: import time…
-
1
votes3
answers316
viewsExercise changing last element
exercise: Write a function that receives a phrase and an old word and a new word. The function should return a string containing the phrase original, but with the last occurrence of the old word…
pythonasked 6 years, 1 month ago Matheus Andrade 205 -
1
votes1
answer146
viewsUse Variable in Button Attributes
I’m creating a small system in python3 using the Tkinter library, in this system there are many buttons and I would like to standardize the colors using a variable, so I don’t have to keep writing…
-
1
votes1
answer107
viewsText Mining python or r
I am trying to extract information from PDF files to popular a table without having to read the PDF. Only I can’t find any references that indicate how to do this. I need, for example, to discover…
-
1
votes0
answers43
views'Useradmincreatinform' Object has no attribute 'get' Django
I was trying to send data from a user to the database and received the following error. from django import forms from django.contrib.auth.forms import UserCreationForm #from django.contrib.auth…
-
1
votes0
answers494
viewsHow to modify the text of a button by pressing it?
I am very new in this field of programming with graphical interfaces and I am with a project with Arduino... The communication part is OK, but I can’t do anything simple like: Change both the color…
-
1
votes2
answers544
viewsYellow comment on Pycharm when using the term "all"
I wonder why my comment gets the yellow color. It always happens when I use the word 'all'.…
-
1
votes3
answers105
viewsError on average of students
I developed the following algorithm to calculate student averages: matricula = int (input("Digite a matrícula do Aluno: ")) nota1 = float (input("Digite a primeira nota do aluno: ")) nota2 = float…
-
1
votes1
answer722
viewsHow to plot graphically with the colors of each pixel of the image?
I am working on the color recognition of images, with this, I am converting the RGB image to Lab, because it is the color space closest to the human view. Once this is done, I take each of the 3…
-
1
votes1
answer119
viewsConvolution 1D Keras
In my code, I have a matrix (820.53). I’m trying to perform a 1D convolution but always get the following error: Error when checking input: expected conv1d_1_input to have 3 Dimensions, but got…
-
1
votes1
answer376
viewsHow to break line inside python dictionaries?
socios = {} def cadastro(): addSocio = input("Digite o nome do sócio que deseja cadastrar: ") telefoneSocio = int(input("Digite o número de telefone do sócio (DDD + NÚMERO): ")) cpfSocio =…
-
1
votes2
answers912
viewsHow to display an upper triangular matrix?
Write a program that prints a 10x10 matrix that is triangular higher, that is, the elements below the main diagonal are null (or zero). Until then I managed to do this: for linha in range(10): for…
-
1
votes1
answer849
viewsHow to "clean" a csv file with Python?
Hello! I’m extremely new to programming, so I apologize if I can’t explain what I’m trying to do or if my code is really wrong. I have a recurring task in my job which is to open a list of…
-
1
votes4
answers1713
viewsRemoving lines from a numpy array
For example I have array arr1 and I want to take a line range from that array as below, which function I can use? arr1: array([[ 1, 1, 1], [ 2, 2, 2], [ 3, 3, 3], [ 4, 4, 4], [ 5, 5, 5], [ 6, 6, 6],…
-
1
votes3
answers2609
viewsWhat is python’s " "?
I was seeing what it is, ta speaking "xor", but if I give 5 11 results in 14 and 5 5, 0? What exactly is this result?
-
1
votes3
answers69
viewsTransform a list into several within the same
I have the following list: X = [1,2,3,4,5] I want you to stay like this: X = [[1],[2],[3],[4],[5]]
-
1
votes1
answer383
viewsPython - What is Enum?
I used the type function on an object and the returned was: <enum 'Button'>. What does that mean?
-
1
votes1
answer1062
viewsHow to convert a string to Date with the month name in English
I have a df in which the first column dates (13-mai-2019) is as string and I want to convert her to 13-Maio-2019 or 13-5-2019. I used the following code: df['Date'] = pd.to_datetime(df['Date'],…
-
1
votes2
answers56
viewsCategory Names not shown. Object (1)
Can someone help me fix why the category names are not being displayed in my admin console? from django.db import models from django.conf import settings class Cad_pref(models.Model): nomepref =…
-
1
votes0
answers458
viewsProblem with Python Selenium
I made a program to download 64 invoices, it goes well up to the ninth, but when Lenium arrives in it stops clicking without error all Elif take a different id and perform the same action with it,…
-
1
votes1
answer23
viewsHow to Format a Date of Bytes(Pyhon)
Good afternoon I have the following doubt, I would like to print the date as follows for example 5/24/2019 but what this happens is the following print(date) Data: b'20290510113138Z' I have the…
pythonasked 5 years, 6 months ago Pedro Pinheiro 248 -
1
votes0
answers63
viewsHow to add a widget to a Qtablewidget header?
Hello, I want to put a Search Field inside the header of a grid that shows information from the database, for the user, the idea is to have a field for each column, enabling the user Filtre inside…
pythonasked 5 years, 6 months ago Giovanni Lopes 11 -
1
votes1
answer121
viewsLimit array size on screen
I am working with data from a table, but I used some commands like numpy.set_printoptions(threshold=sys.maxsize) to try to show every array without (...) omitting some items. But now I’m willing to…
-
1
votes1
answer14386
viewsTypeerror: string indices must be integers - PYTHON
when I try to list json, it is returning the error: save.append((Infos['web_id'], Typeerror: string indices must be integers Can you help me understand how this happened? I have little experience in…
-
1
votes1
answer124
viewsRabbitmq running on an external server
I have a Django web application that uses Celery for asynchronous tasks and Rabbitmq for Broker management. When both are running on the same machine, tasks are performed smoothly, but the…
-
1
votes4
answers79
viewsProblem with a search algorithm on a vector and does not find
The algorithm I am developing should look for an element in any vector. The error happens when the element is not found. vetor = [] for i in range(1, 5): vnum = int(input('Digite um valor: '))…
-
1
votes1
answer1587
viewssha1 encryption with python
I need to generate a sha1 encryption of a string value from a JSON file, but I’m not getting it. Does anyone know where I’m going wrong with my code? The code opens the json file, takes the String…
-
1
votes2
answers73
viewsHow do I get Django to see the folders on my computer?
I need to make my system see folders that are outside your folder, to render the . pdfs that are inside those folders. I’m using a function in javascript (Vue.js) very simple, similar to this one:…
-
1
votes0
answers17
viewsProblem sending strings with special characters in xmlrpc
I’ve been getting the bug for some time: xmlrpclib.Fault: <Fault -32700: 'parse error. not well formed'> When trying to send the following string via xmlrpc, In the python 2.7 base =…
-
1
votes1
answer415
viewsError connecting Python to Oracle BD
I am unable to connect Python to my oracle database. Displays the following error : import cx_Oracle con = cx_Oracle.connect('topm/[email protected]/xe') print (con.version) con.close() Traceback (most…
-
1
votes1
answer228
viewsWhat is the difference between the behavior of a static method, normal method and class method?
I’m studying python with OOP and sometimes I feel confused when using a certain method. class MeuObjeto(object): def __init__(self, objeto): self.objeto = objeto def metodo_normal(self): //sem…
-
1
votes2
answers661
viewsGet Python logged in user ID
I have a project in Python and Django. Where I have a REGISTRATION class, and in this table I would like to record in the column "Person" the ID of the user logged in the application, in the column…
-
1
votes2
answers274
viewsLimit Simultaneous Access in Django
I wonder if there is any native way of the Djang framework itself to limit the amount of screens per user, I have researched about and can’t find anything to answer that. I want to prevent a user…
-
1
votes5
answers1328
viewsHow to create folders in python desktop
I was hoping to make a python program that would create a folder on the desktop, so I did: import subprocess subprocess.call('mkdir Pasta_Teste', shell= True) But the code created a folder inside…
-
1
votes1
answer507
viewsI cannot list the unique values of the dataframe
I have a dataframe with 1 million lines, I know that to list the unique values would be df['Col'].unique(), but I can’t see them all, because this method shows only the first and last lines, leaving…
-
1
votes3
answers871
viewsUse more than one language in the same project?
I am participating in a project that will need two parts: 1) Extração de dados da internet 2) Criação da Interface Gráfica para Desktop For the first, I thought of using Python for reading that it…
-
1
votes1
answer1971
viewsImport and manipulate json in Python
I am trying to import a . json file with the following structure: short_description:She left her husband. He killed their children. Just another day in America. headline:There Were 2 Mass Shootings…
-
1
votes0
answers30
viewsCreating objects with rpy2
There are two ways to create R objects using rpy2? I have an example: import rpy2.robjects as robjects # Criando um objeto R a partir do Python robjects.r(''' rfunc <- function() { print("ola") }…
-
1
votes1
answer601
viewsTell what is the predominant color
Example: if the predominant color is a shade of red or red it appears a print saying it is red. the code works and returns a value in RGB, what I’m not getting and tell which is the predominant…
-
1
votes1
answer47
viewsSearch and insert do not work together - Flask
Hello, I am doing a job that needs to insert values in the database, return them in a table and be able to delete them through Flask. I am knowing the tool and I could not find solutions. Be able to…
-
1
votes2
answers366
viewsHow to generate a temperature x time graph of data collected by an Adian?
Good afternoon guys, I’m trying to use a program in python to read seven temperature values through the serial port with Arduino, so far the program I’ve done collects the data, saved in a text…
-
1
votes1
answer383
viewsPython Telnetlib connect port other than 23
Hello; I’m trying to make a python script to connect to port 12612 localhost. Running the telnet command on linux, manually, it runs. However, in my python script, using the telnetlib library, it is…
-
1
votes1
answer61
viewsI want to "capture" the path and use it in another program
I have a "ransomware" in which I put a path to a folder and it encrypts/destroys I have a paper to present in college where I have to create a graphical interface, created a simple screen, with 2…
-
1
votes2
answers905
viewscheck symmetrical matrix
The exercise asks you to make a function that checks whether a matrix is symmetric. Rows and columns are respectively the variables i and j the program always returns true, but I don’t know what’s…
-
1
votes1
answer246
viewsGenerate random numbers with fixed total python result
I need to generate three random numbers and the sum of those has to be 1.0. follows the idea more or less, I believe that the way I’m doing would take too long to reach a.. import random total = 1.0…
pythonasked 5 years, 5 months ago andgualberto 27 -
1
votes1
answer242
viewsCalling PYTHON script through PHP
I want PHP to show the result of PYTHON code PYTHON x = 4 * 5 print(x) PHP <?php $teste = shell_exec('python codigopython.py 2>&1'); echo $teste; ?> The result I’m getting is: 'python'…
-
1
votes1
answer1047
viewsZerodivisionerror: integer Division or modulo by zero
The code: janela=[] for i in range(100): if(len(leitura)%i == 0): janela.append(i) The mistake I get is this: Zerodivisionerror: integer Division or modulo by zero…
-
1
votes0
answers255
viewsRoi (Region of interest) customized with Opencv and python
I detect people using Opencv and python, but I need to customize my ROI. I can only draw it rectangular, I would like a custom shape as in the picture.…
-
1
votes1
answer385
viewsHow do version control ( git, version control) using notebook jupyter?
I recently started programs in Python using the Jupyter Notebook (web) and wanted to give a push in my Github repository. I cloned my repository through cmd, I changed the document, I did a lot of…