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
-
0
votes1
answer83
viewsBasic error in python
I created this script, but is giving this following error: print('Choices\n1-Option 1\n2-Option 2\n3-Option 3') if choose =='1': print('The account is 5+5') elif choose =='2': print('The account is…
-
0
votes1
answer420
viewsHow to test connection to Mysql database (sqlalchemy)
I started learning unit tests recently, Not I know if unit testing is really the term I’m looking for, but how can I "test" the database connection ?
-
0
votes1
answer198
viewsMaintaining the relationship between vector elements after a Python sorting
I have two vectors X and Y, I want to plot an XY graph with them, that is, the element at position X[0] corresponds to element Y[0] and element X[1] to Y[1] and so on. But my vector X is disordered,…
-
0
votes1
answer84
viewsSet attribute of another Python class
I am studying python and would like to understand how I can define an attribute of a class based on attributes of another class. I’ll go to the example to be clearer, it’s just an example of what I…
-
0
votes1
answer53
viewsDates in python
How can I get multiple different dates in the same run as my script? I got my script done this way: from datetime import datetime, timedelta Time = '{:%H:%M:%S}'.format(datetime.now() +…
-
0
votes0
answers274
viewsDjango form linked to registration
I have two tables in Django (Game and Goal) and I’m trying to create a form for them: class Jogo(models.Model): ativo = models.BooleanField(default = True) dataHoraInicio =…
-
0
votes1
answer25
viewsSend text fixers by python smtp
Exists some way to send fixers .txt by python smtplib? This is my current code: server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(Sender, Password_SMTP) server.ehlo() body =…
-
0
votes0
answers54
viewslist index out of range, reading data and saving a variable
Hello! I need to read a data that is in a list at position 13 and is repeated every 15 values. Using the following code I receive error message: for i in range(0,len(dado),15): lat = texto.pop(13+i)…
-
0
votes1
answer33
viewsWhat is the logic required to obtain the coins used in my algorithm?
I’m analyzing an algorithm that returns the minimum number of coins to be used from a penny value. def numero_moedas(centavos): if centavos < 1: return 0 moedas = [50, 25, 10, 5, 1] n_moedas = 0…
python-3.xasked 5 years, 3 months ago Sidney Ramos 3 -
0
votes1
answer543
viewsValueerror: Cannot assign "'1'": "User.campus" must be a "Campus" instance. Super User registration error in Django
I’m developing an application where the user needs to be on a campus. However when superuser is created in the terminal an instance error occurs. Note: The database is correctly pre-filled to fetch…
-
0
votes1
answer25
viewsPython3 Tkinter error
good night, The idea of this code is to insert an image in a graphical interface but this always giving the error and says that can not open the image Someone knows what’s going on? this is my code…
-
0
votes1
answer531
viewsHow to make this program repeat itself?
Which command is useful for running the program from the beginning to the end?? f=float(input("Digite 0 para retânglo, 1 para triângulo:")) if f==0: a=float(input("valor da altura:"))…
-
0
votes1
answer214
viewsHow do I make 3D work on pyglet?
I was trying to create using Opengl, Python and pyglet, a flat triangle in a 3D space, I saw some tutorials on the internet, some videos on Youtube, and in the end I wrote this code down there, the…
-
0
votes1
answer2830
viewsConverting Bases to Python
The code below takes a decimal number and converts to bases from 2 to 9 def converte(numDecimal, base): if numDecimal != 0: numConvertido = "" while numDecimal > 0: resto = numDecimal % base…
-
0
votes1
answer280
viewsError trying to install Mysql Client
I’m trying to install mysqlclient on Windows using Pip, so I can use it on Flask, but when I try to use Pip install on CMD (with the files downloaded on the site…
-
0
votes1
answer756
viewsconnect matplotlib points
My program plots independent points but I would like to connect the a_min's and a_max's. How can I do that? In this case, there would be two parallel lines. He’s filling up like this: '''…
-
0
votes0
answers110
viewsHow to save and finish python code?
I’m using a camera to capture video, and save the video. I’m trying to save and finish the code with a command in the IDLE(python) but I’m not getting it. Actualement to finish and save the program…
-
0
votes1
answer751
viewsincrease the size of matplotlib numbers
How can I increase the size of graph numbers (those marked on x and y axes) in matplotlib? Similar to changing font size.
-
0
votes1
answer41
viewsPython Beautifulsoup doubt
I am making a requests.post and it returns me the following information: {"Name":"Joey Triibianni","Vocation":"Knight","Level":"425","World":"Quelibra","Account Status:":"Free Account"} I’ve tried…
-
0
votes1
answer58
viewsSyntaxerror without apparent errors
import sys entrada = input("DLL Nome: ") saida = entrada+"_output.txt" file = bytearray(open(entrada, 'rb').read()) with open(saida, 'w') as output: for count, byte in enumerate(file, 1):…
-
0
votes1
answer321
viewsSwitch Windows Screen with Python
Good Afternoon! Guys, I’m writing a Python script using the Pyautogui library. At some point, this script "needs to navigate between screens", example, my script is working a report within my TMS…
-
0
votes1
answer142
viewsHow to create an Array within the other
I need to create an array that has Indice and values page_links receives the links of a page all_links_main = [] for link in page_links: all_links_main.append(link.get('href')) produto = [] for…
-
0
votes2
answers356
viewsSetting parameters and filtering file . TXT
I have a file with a tab | in file . txt, would like to turn it into file .xls and then work with it by filtering and replacing values in python3. And possible ?! Follow a template of the file ".…
-
0
votes0
answers64
viewsHow to multiply all values within a list?
Hi, I’m developing a program that gets a list of bases and exponents. Thus, it performs the potentiation between them and, soon after, multiplies the results. However, I am dubious about the…
-
0
votes1
answer459
viewsError while using urllib library
I’m trying to make a simple application Hello World taking a look at documentation with the library urllib with the aim of picking up content from a specific website. I will refine the content I…
-
0
votes1
answer97
viewsConvert date string to date
I need to convert the date of format 'Aug 29, 2019' to 06/08/2019 however I am not getting with strptime, Follow the error. Valueerror: time data 'Aug 29, 2019' does not match format ' %m %d, %Y'…
-
0
votes0
answers57
viewsI need some help on batteries
I need to create a new list with the values of a string, without repeating the previous digit. If it were only not to put duplicate values, it would be easier, but the rule is not to repeat the…
-
0
votes1
answer139
viewsHow to use Join in an object list?
class Pessoa: def __init__(self, nome, idade): self.nome = nome self.idade = idade p1 = Pessoa('João', 15) p2 = Pessoa('Maria', 17) lista_pessoas = [p1, p2] How to use the join() to print the list…
-
0
votes1
answer100
viewsHow to remove repeated values from a dictionary?
For example: A = {2:5,4:5,7:8,9:8,11:10} Must return B={11:10} to remove the repeated values.
-
0
votes0
answers191
viewsHow to use 4 boxes after the comma in Python 3
I need to calculate the circumference area being: area = π . radius². Considering for this problem that π = 3.14159 (is my n) raio = float(input('insira o raio: ')) n = 3.14159 area = round…
-
0
votes1
answer183
viewsQwidget class inside Qmainwindow class
I have the following code: # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton from PyQt5.QtWidgets import QSpacerItem, QLabel, QComboBox…
-
0
votes1
answer5443
viewsConvert str(Object) to int (python)
I have a dataset with two columns and would like to create a third column called Ranking that will receive values based on the Brand column. So Mark A will receive the value 10 and so on. df =…
-
0
votes3
answers158
viewsAccess a value on an if condition
Is there any way to access a value passed on the condition of a if? For example: a = int(input('Digite um numero: ')) b = int(input('Digite outro numero: ')) if((a-b) > 0): print(f'O numero…
-
0
votes1
answer83
viewsUnable to convert string to float
I am trying to run a classification model and I am getting the feedback that it is not possible to convert string to float in the predictive variables. When I give a dtypes I see that all variables…
-
0
votes1
answer135
viewsHow to print with Pyqt5?
I made a little program in Pyqt5 where I type the Name, Number, Phone,Address, description of services and values. Now I want to print it out as a budget, but using that function: def…
-
0
votes1
answer267
viewsError using Lower(), upper() and title() functions
I have the following problem, when trying to use the functions lower(), title() and upper(). My compiler simply won’t allow and displays the error AttributeError:'list' object has no…
-
0
votes2
answers53
viewsLibrary import
A while ago I had a question about importing libraries (here: Why should we import Messagebox explicitly into Tkinter even importing with the asterisk?) and explained to me that, in that particular…
-
0
votes1
answer273
viewsHow to transform excel file into list? Python
I wonder how I can turn the excel file into list after reading it df = pd.read_excel('Data.xlsx')…
-
0
votes0
answers496
viewsReverse for is not a Valid view Function or Pattern name. only happens in production
I do not work long with Django but I come here turning around + now I fall into this problem I am not able to solve, so I ask for help from those who can. I have my application working in perfect…
-
0
votes1
answer187
viewsDifferent global variables that when one is changed change the value at all
I have a class responsible for managing certain call variables clusters, these are a vetor de vetores yesterday contains a word and an associated value. But every time I make an adjustment to the…
-
0
votes1
answer355
viewsFunctioning Chained List
I’m trying to implement a chained list scheme in Python and was debugging the code to better understand how it works. I’m curious about some things. The code I’m implementing is as follows:: class…
-
0
votes1
answer56
viewsHow can I replace this regular expression using Beautiful Soup
Currently I use this expression to extract everything below the tag <b> until I find another tag <b>: blocks = re.findall(r'<b>.+?<b>', str(element)) How can I do the same…
-
0
votes1
answer141
viewsPool and Transactions with Pymongo
I am making use of Mongodb + Pymongo for the first time, I am looking for information on how to work with Connections Pool and Transactions with pymongo. To date with the documentation found the…
-
0
votes2
answers526
viewsApply a function to each element of a python matrix
I need to apply a lambda function to all elements of a matrix in and it returns a matrix of the same size type like this: i have the matrix mat in numpy style: mat = array[[1, 2, 3], [4, 5, 6]] and…
-
0
votes0
answers33
viewsWhat are Python commands with underscore at the beginning and end?
I realize that some scripts in Python have expressions with commands like this: __name__ == “__main__”' __str__,__repr__ self.__class__ self.__dict__ What are these commands that start and end with…
-
0
votes1
answer5223
viewsHow to manipulate CSV data in python?
I need to manipulate data CSV without using pandas or numpy. It has specific columns to manipulate, so how do I best go through the columns, do this data reading of each one and be able to work with…
-
0
votes1
answer502
viewsQual é a diferença entre os.path.dirname(os.path.abspath(__file__)) e os.path.abspath(os.path.dirname(__file__))
The two seem to return exactly the same. Inclusive, os.path.dirname(__file__) returns the same too.
-
0
votes1
answer756
viewsDoubt in Python request Django GET/POST
Good evening, I have a problem that I cannot solve in Python 3.6.7 and Django 2.1.1 I have the following codes: views @login_required def profile_provider(request, provider_id): provider =…
-
0
votes1
answer28
viewsGeneric relationship between model Logentry
Someone has worked with Auditlog on Django ? Documentation of Django Auditlog Let’s say I have this model: class Cadastro(models.Model): nome = models..TextField() auditlog.register(Cadastro) I…
-
0
votes2
answers967
viewsI want to close a python file and then open it again
Do not call the variables name. When the program tries to open the file after closed, it does not open. from time import strftime n = 2 cl = 2 abrir_arquivo =…