Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes0
answers43
viewsHow to know how much storage was occupied by a Python/Django application?
I developed a web application with Python and Django. I would like to limit the amount of space used for each user, because in the application it is possible to insert images and documents. I use…
-
1
votes1
answer137
viewsPython Script Creation 3
I’m doing an exercise: A factory has 10 representatives. Each receives a commission calculated from the number of items in an order, according to the following criteria: - for up to 19 items sold,…
python-3.xasked 5 years, 12 months ago Rodrigo Rodrigo 11 -
1
votes0
answers18
viewsHow does this interaction work within a list?
After searching on how to create lists with random sizes to perform some exercises I found the following line of code that satisfied my doubt but that created another x = [i + 1 for i in range…
python-3.xasked 5 years, 6 months ago Big Nerd 13 -
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
votes1
answer61
viewsIs it necessary to create an app for each entity in a Django project?
I wonder if it is a good practice or if it is a very "extreme attitude". Example: My project has user, client, subscription and product entities. I can create an app with all these entities or…
-
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
answer297
viewsFilter python list
I need to remove elements from a list whose item reference for removal is in another list: # Esta lista foi gerada por combinação lista original=[ (182361, 243148, 360624, 364188), (182361, 243148,…
-
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
votes1
answer50
viewsCorrect way to execute query in Django?
I need to execute the query SELECT pg_database_size('mydatabase'), how do I do this in Django with the SGBD Postgres? This is what I’ve tried from django.db import connection cursor =…
-
1
votes1
answer748
viewsHow to make a program run inside a pygame window?
I made a window using pygame, and I have a code that I wanted to run inside it, but I don’t know how to do that, if anyone can help I’m very grateful. Here the window code: pygame.init() tela =…
-
1
votes1
answer825
viewsCopy part of Dataframe where column is Null or Nan
I have the following doubt. I have the following sample dataframe: import pandas as pd df = pd.DataFrame({'A' : [4,5,13,18], 'B' : [10,np.nan,np.nan,40], 'C' : [np.nan,50,25,np.nan], 'D' :…
-
1
votes3
answers732
viewsWrite a function that returns the larger of two numbers passed as arguments
I wanted to do this function by grabbing the keyboard input but I’m not getting. def bigger(a, b): a = input('informe um valor: ') b = input('Informe outro valor: ') if a > b: print('O valor a é…
python-3.xasked 5 years, 5 months ago Thanos 11 -
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
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
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
answer75
viewsHow to obtain items that multiple lists have in common
How to do for when there is no common item, launch warnings? List 1, 2 and 3 have different index numbers. def compabilitySorter (lista1, lista2, lista3): listCompatible=[lista1, lista2, lista3]…
-
1
votes0
answers162
viewsDjango project deploy on Heroku with errors
When trying to deploy my Python project using Django on Heroku, I am getting the following error. Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2),…
-
1
votes1
answer458
viewsWhat is the equivalent of "from" and "import" (PYTHON) in Ruby?
I would like to call a script through another script. In Python I use the commands "from" and "import", but which command would be equivalent to do this in Ruby?
-
1
votes3
answers484
viewsI can’t make the Pygame window close button work
I’m learning to use Pygame functions, but I got caught up in this problem. I created a window with Pygame, and then I made this code so when I click the exit button the window closes. Code while…
-
1
votes2
answers109
viewsClick using Webscraping with Selenium
I am starting my studies with Webscraping and I have the problem at the time of giving a second click on a new page. I am trying to access my email using Selenium, I can fill my email and click to…
-
1
votes1
answer173
viewssum the database values and display the result in the flask-sqlalchemy template
have ma table with following information: class Registro(db.Model): id = db.Column(db.Integer, primary_key=True) valores = db.Column(db.Float) ------------| valores | ------------| 1.50 |…
-
1
votes0
answers361
viewsI have a little problem with listbox - in Tkinter
Good morning, I have a question about the listbox on Tkinter. my code is working fine, there’s only two things wrong and I’m not getting it fixed. first that when I click the delete button, the…
-
1
votes1
answer639
viewsThe Pytesseract does not recognize only one letter
I need to recognize only one letter through the Pytesseract library in python but OCR is not able to recognize when it is only one letter. In this case, I’m trying to recognize the letter H, but…
-
1
votes1
answer110
viewsHow to keep the window created by Pyqt5 open?
After studying the object orientation part for a long time I started to study Pyqt5. I was doubtful in the following code: class App(QWidget): def __init__(self): super().__init__()…
-
1
votes0
answers89
viewsCircular Graph for Python Correlation Analysis
Good afternoon: I’m a beginner in python. I wonder where I can find study material to generate circular graphs for correlation analysis in python similar to the figure below (in the language R). I…
python-3.xasked 5 years, 10 months ago Rodrigo Ferraz 309 -
1
votes1
answer661
viewsHow to reduce the runtime of a python script?
I have been for a few days trying to solve a programming problem that involves searching to find the union and the intersection between sets. I managed to solve the problem with small sets, but when…
-
1
votes2
answers69
viewsFind out if a timedelta object has any negative attribute
I have a function that takes a parameter of type timedelta. I’m looking for ways to know if the object passed by parameter has any of its attributes (days=0, seconds=0, microseconds=0,…
-
1
votes1
answer48
viewsPass Descriptor by parameter to another Descriptor
Let’s imagine that in a class I have two properties of the Scriptor type. The first of them ensures that the property in question is negative the second must ensure that the property associated with…
-
1
votes3
answers65
viewsHow to join the score with the last word on the left?
It may sound like a silly question, but I really didn’t find an answer in my readings. I created a program whose purpose is to calculate my Coefficient of Performance and the percentage of the…
-
1
votes1
answer76
viewsWhen I hit the word, an input still appears at the end
I’m developing a guessing game in Python, but when I hit the word at the end still continues to appear a input. CODE: import random…
-
1
votes1
answer5197
viewsRequest Python form/data
Guys I made this request in Python but not enough data in API, made in Postman works perfectly. API_URL = "https://api-us.faceplusplus.com/facepp/v3/detect" api_key = "7Z...uC" api_secret =…
-
1
votes1
answer904
viewsPython3 Tkinter method Stroy
good night, I was working on a project that involved a graphical interface and decided to use Tkinter to produce it I read about a method called Destroy() but could not find a way to use it the goal…
-
1
votes0
answers57
viewsDjango error - 'agenda' is not a Registered namespace
py apps. from __future__ import unicode_literals from django.apps import AppConfig class AgendaConfig(AppConfig): name = 'agenda' py. from django.conf.urls import url from . import views from…
-
1
votes2
answers82
viewsInstantiate class by passing only a few parameters in Python 3
Good afternoon, everyone I created a very simple python class with a constructor __init__. The constructor expects to receive 3 parameters, and the 3 have default value. I would like to know how to…
-
1
votes1
answer235
viewsWord repetition
I’m developing an algorithm that sings the elephant’s music, I think everyone knows it. Who doesn’t, it works like this: a) For the first elephant, write in the singular. b) For the second elephant…
-
1
votes1
answer495
viewsIndexerror: list assignment index out of range
I tried to solve the exercise https://python.nilo.pro.br/exercicios/capitulo%2007/exercicio-07-09.html and even the template presents an error: Traceback (most recent call last): File "teste.py",…
-
1
votes1
answer513
viewsObject counter by an infrared sensor on Raspberry with Python
Hello friends I made an object counter using an infrared sensor and Python, but would like help to refine the code. Because this counter of mine has a problem, if the object stops in front of the…
-
1
votes0
answers75
viewsString field in Mysql returns as bytearray type using Python
When performing a query in Mysql using Python, I get a return of type bytearray, being that the column is of type String. import mysql.connector as myc # conexão MySQL conMySQL = myc.connect (host =…
-
1
votes0
answers50
viewsProblem saving number of items read in variable
The code has the idea of only reading how many times the highest array value repeats. num_velas = int(input('Número de velas: ')) alturaVelas = [] alturaVelas = input('Qual a altura das…
-
1
votes1
answer143
viewsVariable changes value when calling function
I created a variable v, who receives n random numbers. when create another variable by calling a function and passing v by parameter, the v mute. n = int(input("Entre com o tamanho de vetor: ")) v =…
-
1
votes0
answers90
viewsI have a Python error
I have the following code saved as main.py import nltk from nltk.stem.lancaster import LancasterStemmer stemmer = LancasterStemmer() import numpy import tflearn import tensorflow import random…
-
1
votes2
answers2327
viewsPython code error - Syntaxerror: can’t assign to Function call
I’m doing a futsal game with POO, and I went to do a function outside the class and in the global scope assigns the vector lista_team = [], only when I’m trying to run the stage where the code is,…
-
1
votes0
answers65
viewsHow to update a list in Tkinter
Good afternoon! I created a function that updates the "mylistcolum" list according to the fields of a table searched in sqlserver. The event that activates this function is the click on a list of…
python-3.xasked 5 years, 9 months ago GabrieleN 11 -
1
votes1
answer80
viewsDoubt Python Code and Opencv2
In this code I can do facial detection from a webcan. I use my notebook camera. I want this code to send a text message, for example "Detected Person" every time it detects a face. I tried to put an…
-
1
votes1
answer29
viewsHow to set a variable in the first call to a function, and keep this value in the second call on
I have a function that arrow a variable after going through an extensive list, which takes a certain amount of time. The program calls this function other times because it is responsible for filling…
-
1
votes1
answer132
viewsPrint Status in a single line
It is possible to make a status report of the script via terminal? For example, I have a function called test, before it is executed, the script displays in the terminal: 'Run test…
python-3.xasked 5 years ago user68537 -
1
votes1
answer34
viewsDjango form for single key
Good afternoon, everyone. I have a model in Django with a field - phone - which is a unique key: phone = models.CharField(max_length=11, unique=True) I’m trying to generate a form in which the user…
-
1
votes1
answer190
viewsAttributeerror: module 'plotly.validators.layout.template.data' has no attribute 'Isosurfacesvalidator'
I have an interactive graph in python. The code below works in Azure Notebook, but I had to migrate my code to Jupyterlab and it shows the following error: Attributeerror: module…
-
1
votes1
answer48
viewsSaving relationships using the Django Rest Framework
When I try to save a new student informs the error NOT NULL Constraint failed: student_student.teacher_id Can someone help me? class Teacher(models.Model): name = models.CharField(max_length=128)…
-
1
votes2
answers242
viewsWhat is In[]: and Out[]:?
For some time I am writing some basic scripts with Python, in some tutorials sometimes I come across In []: and Out[], Usually equal values appear to the forehead. Below is a small example. In [24]:…