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
answer407
viewsSpecific chunk break in JSON file with python
Is it possible to break a line from a specific section of Json, transform it into an array, and then streamline it? Why do I ask this.. I am developing a file mining bot and came across a situation…
-
0
votes2
answers1260
viewsHow to paste a dataframe over a pre-formatted Python worksheet?
I have a template pre-formatted in Excel this way. I would like to paste values from a dataframe into pandas on these cells, creating a new file formatted with values and keeping the original file.…
-
0
votes2
answers4222
viewsHow to find and show the position of an item in the list, not setting the string value for the search?
How to find and show the position of an item in the list, not setting the string value for the search? Ex: nome_pessoa = str(input('Informe o seu nome completo: ')) lista_nomes = nome_pessoa.split()…
-
0
votes1
answer76
viewsIs there any way to reference an Enum inside itself in Python?
I would like to use a constant I created in an Enum as an attribute of another, for example: from enum import Enum class Jokenpo(Enum): PEDRA = ('Rock', [Jokenpo.PAPEL], [Jokenpo.TESOURA]) PAPEL =…
-
0
votes1
answer258
viewsForm in Flask does not work
When I click the Send button nothing happens, if I leave a blank field, idem. File Routes.py from flask import * from forms import * app=Flask(__name__) @app.route('/') @app.route('/home') def…
-
0
votes1
answer69
viewsCode Mandelbrot set
I am studying a specific code of the set of Mandelbrot (equation with complex numbers) with a focus on object-oriented programming. However, there is a specific part I did not understand of the…
-
0
votes1
answer808
viewsHow to separate each element from a list, with a String, in a row
The problem is simple, I would like to add an element to a real-time generated list for each given iteration. For example, if the list l is generated through [x for x in range(10) if x%2==0], then I…
-
0
votes1
answer140
viewsPython Method resolution order (MRO)
Let’s say I have something like this: # -*- coding: utf-8 -*- class Base(object): @classmethod def foo(cls): pass def grok(self): pass class A(Base): @classmethod def foo(cls): print('A')…
-
0
votes0
answers60
viewsResult of paged loop instead of unified
I’m having trouble getting a result formatted in JSON paged. My code instead of returning the result of the joined is bringing the result per page! import requests def __init__(self, usuario,…
-
0
votes1
answer479
viewsParking class in Python
I’m learning to code in Python. Right now I need to implement a class that has the following features: A class called parking, which simulates the operation of a car park. -The class receives an…
-
0
votes2
answers231
viewsread a txt file and list approved candidates
Read a 'data.txt' file (attached) and list the approved candidates. The.txt data file is organized into six columns, separated by ";" and with the following content: column1>Cód. Mat,…
python-3.xasked 6 years, 4 months ago Wendson Oliveira 11 -
0
votes1
answer227
viewsPandas: How to make a Serie fragment in the field (Column) of the Dataframe
I have this excel below: NÚMERO "URL NÚMERO 16571 SICAN" "URL DECRETOS 2011 PRINCIPAL" 1 CCIVIL_03/Atos/decretos/1991/D00001.html CCIVIL_03/decreto/1990-1994/D0001.htm 4…
-
0
votes1
answer51
viewsHow do I hold forever when the <Down> key is pressed and gain +10? (Python3 + Tkinter)
from tkinter import * from tkinter import messagebox jan = Tk() jan.geometry("500x500") Quadrado = Frame(jan,bg="#B0C4DE", width=25, height=25, bd=3,…
-
0
votes1
answer49
viewsPython - Doubt about imports in the creation of libraries
If I’m creating a library, and I put in it import json, in my main (my main file) I would have to import the json or just import from my own library? Thanks for your help.…
-
0
votes1
answer122
viewsPython Problems with Too Big List
I’m making a Python script and I’m getting an msg error I can’t fix x = [int(e) for and in input(). split()] msg of error: Memoryerror Command exited with non-zero status (1) tried to use map: x =…
python-3.xasked 6 years, 1 month ago weltonvaz 343 -
0
votes1
answer283
viewsrecover txt file formatted with utf-8 in python
Good night! I’m having trouble recovering files. txt with python for popular lists or dictionaries, the problem is that these files do not come with uft-8 formatting. example of txt content: what is…
-
0
votes1
answer35
viewsDoubt of lists python3 Conway Game of Life
Good afternoon to you all! I’m currently working on a diagram, where each element is a list. For list entry, I made the following command line: diagrama_entrada=[] x=True while x: l=input() if not…
python-3.xasked 6 years, 4 months ago Gabriel Marangoni 11 -
0
votes2
answers107
viewsHow do you inherit a pygame class?
When I run this code (this is the current entire code, ie only 3 lines): import pygame class sp(pygame.sprite): pass I get: Typeerror: module() takes at Most 2 Arguments (3 Given) I would like to…
-
0
votes0
answers398
viewsBringing files, classes and methods from another Python file
I need to bring a class file like this that is in class.py: class Despesas(object): def __init__(self): self.Prioridade = Prioridade() self.Situacao = True self.Valor = 0.0 self.Categoria = '' To…
-
0
votes1
answer95
viewsDoubt about object orientation in Python
I’m a classmate we were doing a script I wrote my script in this way: detalhes = programa.duracao if hasattr(programa, 'duracao') else programa.temporada In my case, I’m calling it that way! My…
-
0
votes2
answers901
viewsHow to hide a Widget?
I need to know some way that by clicking on Button "hide" a widget (a Label for example) from my window, being possible to use it later; Using place in widget you wish to "hide" (Yes, MUST be the…
-
0
votes2
answers116
viewsTry and except block
I need to carry out this program: Rewrite your payment program using Try and except for that the program treats non-numeric entries amicably by printing a message and exiting program. The following…
-
0
votes1
answer945
viewsHow to print the balance in ascending order and calculate interest in python
Personal I have a job in which I must reproduce the following table: I don’t have much knowledge in python and am doing my best to try to reproduce it. But I am managing to return only in this way.…
python-3.xasked 6 years, 4 months ago Sandson Costa 509 -
0
votes0
answers257
views'int' Object is not subscriptable
I have a problem with the following code: for x0 in range(len(matriz)): # Abaixo foi aplicada a fórmula de transformações lineares para linhas e colunas. xn = transformação[0][0] * x0 +…
python-3.xasked 6 years, 4 months ago Gabriel Viana 1 -
0
votes2
answers102
viewscreate random number in python starting with the year
hello I am trying to create a variable to return me a protocol number catching the current year after 4 front houses starting from the smallest to the largest, example. 20180001, 20180002 etc. to…
python-3.xasked 6 years, 1 month ago Gustavo Cruz 17 -
0
votes1
answer84
viewsDoubt Python libraries
Good afternoon! I am new to development using the Python language, I would like some good library tips to be studying and mainly one aimed at "manipulating websites" (currently I only know the…
-
0
votes1
answer836
viewsExport a dictionary to file . txt
Hello. I would like to know how I export a dictionary to a file. txt. and how to import the data that is in the.txt file into the dictionary in the program. When I care, the dictionary gets all…
-
0
votes2
answers99
viewsinvalid.syntax appears when the program is run
I’ve tried to put palavra = '' and the same error keeps appearing: lista = [] i = 0 while (palavra != 'Sair') or (palavra != 'sair'): i += 1 palavra = str(input('digite alguma palavra: ')…
-
0
votes1
answer68
viewsProblem compiling code in Keras
I was creating a simple classifier in Keras in Python3, but its getting the same error message: Runtimeerror: You must Compile your model before using it. Follows the code: import keras from…
-
0
votes0
answers135
viewsI cannot run the code because Pycharm says that the App class was not created
Pycharm says the App class has not been set, but it doesn’t make any sense since I created the App class. from tkinter import * class App: def __init__(self,master): frame = Frame(master)…
-
0
votes1
answer166
viewsTreat functions that return multiple Python values
For example, I have a function mergeSort(alist)that has return return count, blist i.e., returns an integer that is the inversion counter and a list of values. When passing a list 5 4 3 1 2 5 and…
-
0
votes1
answer157
viewsPython3 in module named tld
I’m trying to use tld https://pypi.org/project/tld/ and I can’t use it in python3, only in python 2.7, which doesn’t suit me, since my whole project is in python3. The documentation says it is…
python-3.xasked 6 years, 1 month ago Antony Leme 197 -
0
votes1
answer295
viewsScraping using Selenium and Beautifulsoup
I’m trying to make a Crap on a book blog, I need to get the titles and categories of all the books posted. In the first attempt, I got an Attribute Error, which should happen several times because…
-
0
votes4
answers685
viewsOnly put the correct message print once
I’m doing this show: Develop a program that requires typing of a CPF number in format xxx.xxx.xxx-xx and indicate if it is a valid or invalid number via validation of check digits and formatting…
-
0
votes1
answer590
viewsCode evaluation: Logistic regression with K fold validation. Is that correct?
The code below is an attempt to make a logistic regression with k fold cross validation. The idea is to take the confusion matrices generated in each fold and then generate an average confounding…
-
0
votes3
answers1982
views"for" with step "float": Typeerror: 'float' Object cannot be Interpreted as an integer
I want to loop 0 to 100 with step 0.1: for x in range(0, 100, 0.1): a = cos(radians(x)) But I get this mistake: Typeerror: 'float' Object cannot be Interpreted as an integer How can I make a loop…
-
0
votes2
answers3618
viewsGrab specific column csv with python
I have a method that opens a CSV file but would like to go straight into a specific column, I tried to do it this way list2 = [row.split()[3] for row in f], but returns a piece of the file and not…
-
0
votes2
answers926
viewslimit the number of digits Entry - Tkinter
Hello. How do I limit the number of digits I can put into one Entry module Tkinter? from tkinter import * root = Tk() entrada = Entry(root) #Quero limitar para que nesse entry, possa colocar apenas…
-
0
votes1
answer51
viewsIs it possible to write all the paragraphs that the user only put after the loop in sequence? and in a justified way?
Is it possible to write all paragraphs that the user has put only after the loop in sequence? and in a justified way? import textwrap numero_paragrafos = int(input('Quantos parágrafos tem o…
-
0
votes1
answer508
viewsConvert Python3.7 to exe
I am creating a "game" with no graphical interface, to distract me from that accustomed programming of everyday life. Using Python3.7.0 and Sqlite3. I would like to 'protect' the game’s source code…
python-3.xasked 6 years ago Carlos Pereira 11 -
0
votes0
answers110
viewsCollision problems in Tkinter (game)
I’m learning Tkinter developing a little game but I’m in trouble to erase objects collided with find.overlapping from tkinter import * from constantes import * import random class Jogo(): def…
-
0
votes1
answer42
viewsError adding items to a file. txt Python3
I’m trying to read a file . txt (currently empty) to check if chat_id already exists, if it already exists, it ends right there. If it doesn’t exist... Add the new chat_id in the last line, but when…
-
0
votes1
answer422
viewsADD Column - Django
How can I add a column to a table in the database using Django? I tried the following migration and did not update my table: from Django.db import models, Migrations class…
-
0
votes0
answers38
viewsPython3: How to treat relative paths with module os
I’ve got it down: def get_conteudo_file(filename: str, encoding: str="iso8859-1") -> str: filename = os.path.abspath(os.path.join(*filename.split(os.sep))) assert os.path.isfile(filename),…
python-3.xasked 6 years ago britodfbr 688 -
0
votes2
answers286
viewsPython: How to identify the root of the operating system?
As I identify the root of the operating system (windows: "C: ", No linux: "/"), exclusively through python commands that apply to both systems?
-
0
votes3
answers178
viewsis not accumulating values in the lists
list1=list() Lista2=list() def lê_e_verifies(): """reads an integer and checks whether this correct returns the integer read""" while True: try: inteiros= int(input("entre com numeros1 ")) inteiros=…
-
0
votes1
answer311
viewsHow to reverse the association of one file to open with another in Pycharm
I picked up a song I copied and glued to the pycharm. The song was not recognized, appearing the option Associate with file type, when I clicked associated the program to youtrack query , as I do to…
-
0
votes1
answer69
viewsoutput function giving error syntax
lista1 = [1,2,3,1,1] lista2 = [2,2,3,1,3] res = list(input("Digite seus inteiros")) def exibiçao(lista1,lista2,res): print("{} {} {} {}…
-
0
votes1
answer333
viewsMessage in "print" is not printed on the screen, how to fix?
The message of print does not appear on the screen, does it have to do with the variable? cp = str input("seu nome") if(cp)=='jefferson': print('JFP')
-
0
votes2
answers41
viewsDoubt about inserting content from a file . txt to a list
I have a question about inserting the contents of a text file into a python list. I want to put the first line of a text file in a list. In my code it performs the task but the following message…
python-3.xasked 5 years, 11 months ago Rodrigo Ferraz 309