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
votes2
answers402
viewsStrings in python
I know the basics of coding strings in Python, but I still cannot go forward and complete the whole requirement of the statement. I don’t know how to encode the quantities you require in the…
-
0
votes1
answer458
viewsSave Excel file to Python via Scrapy
As I do for mine Spider save all Excel data in a single XML file links which I extract? Or also save in each single XLS file in the project folder? Part of my Spider: def parse(self, response): divs…
-
0
votes1
answer67
viewsError trying to encrypt with BCRYPT in Python
Code: import bcrypt hashed = bcrypt.hashpw('teste',bcrypt.gensalt()) error: Typeerror: Unicode-Objects must be encoded before hashing Running the program shows this error, how can I fix?…
-
0
votes2
answers720
viewsPython 3 and Tkinter: progress bar does not update during script execution
Hello. I am creating a layout converter using Python 3.6.4 and Tkinter. Among other things the GUI must have a progress bar that updates its value with each interaction of the conversion process,…
-
0
votes3
answers9117
viewsconvert a string list into a list of integer numbers
x = ['443' , '552' , '342' , '368' , '9867' , '335' , '9412' , '7436' , '1692' , '85' , '990' , '332' , '8816' , '4567' , '279' , '119' , '2290' , '234' , '9863' , '345' , '230' , '5574' , '230' ,…
-
0
votes1
answer130
viewsInfinite wait per server response using python sockets
I am trying to send a message to a server API in order to get a response. I am using the following code: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address =…
-
0
votes1
answer66
viewsimporting a file containing a function I wrote: no global variable
Constroimatriz.py file: """ Escreva uma função que recebe um inteiro m e outro n e com isso constrói uma matriz mxn """ matrix = [] def main(): m = int(input("Digite o número de linhas da matriz:…
-
0
votes0
answers237
viewsError trying to install mysql-Connector-Python
I have installed version 3.6.5 of Python, and decided to install the "mysql-Connector-python-8.0.11-py3.6", but it returns an error that does not find such an installed version, it will need…
-
0
votes1
answer974
viewsWrite a string list to a file
I have a list and I wanted to write in another file ["AMANDA,"JULIANA","VANESSA","PATRICIA"] In a document using Python, I managed however the file gets all together like this:…
-
0
votes2
answers1305
viewsHow to turn a list into a set in Python?
I’m trying to intersect the player list with the computer list, but I’m getting an error that says "line 13, in print(set(player).intersection(computer)) Typeerror: 'int' Object is not iterable".…
-
0
votes1
answer914
viewsUse return of one method in another method of the same class
I am working with The Guardian API, through two methods, search_content() and data_to_csv(), contained in the Theguardian class. The first method is responsible for searching The Guardian database…
-
0
votes1
answer41
viewsI want my def to print(): ... receive my def mais_alto(): and my def mais_baixo(): and print the results
lista_aluno = [] lista_tamanho =[] def nome_altura(): for i in range(0,10): aluno = str(input('Digite o nome do aluno:\n')) lista_aluno.append(aluno) tamanho = int(input('Digite a altura:\n'))…
python-3.xasked 6 years, 7 months ago Damião José 1 -
0
votes2
answers942
viewsHow to write an alphabetical agenda of Names, if the dictionary structure has no order?
Write a program that receives as many entries as the user wants and then create a new contact for each entry (Name, Phone, Address, Email), and finally prints, in alphabetical order, the contact…
-
0
votes2
answers45
viewsTwo doubts about Kinter
I have two questions about GUI Tkinter. The first is: how do I stop when the text of a label is larger than the label size, the text instead of being missing, continue on the next line. The second…
-
0
votes1
answer38
viewsHow to play a background audio?
I’m making a python program that runs inside an infinite loop.. Under certain conditions I need to play an audio, but I cannot wait for the audio to finish to continue the process. I thought of…
-
0
votes2
answers477
viewsHow to access a private attribute in a class?
Write a program of banks you own: Uma classe Banco com os atributos - private total - public TaxaReserva - private reservaExigida E métodos - public podeFazerEmprestimo(valor) --> bool - public…
-
0
votes1
answer86
viewsStoring past data - Django
My question is the following, in my application I have a profile template that has the following fields: Models py.: class Perfil(models.Model): nome = models.CharField(max_length=255, null=False)…
-
0
votes2
answers3404
viewsTake a Tkinter entry and save to a variable
I made this initial window where I took the data, and when the client used it, after providing the data and confirming it, it closed and kept the data saved in a variable that was not tied to an DEF…
-
0
votes1
answer1253
viewsHow do I prevent user input from resulting in a Valueerror, and ask the program to redo the question
I need to learn how to check if the input will result in a Valueerror, and then re-run the input request until the value is an integer. My problem: QuantidadeCabos = int(input("Digite a quantidade…
python-3.xasked 6 years, 7 months ago TulioBRK 5 -
0
votes1
answer697
viewsHow to find the highest value of a matrix?
Well, I have a 3x4 matrix and I want to know how to develop a python code to get the highest value of this matrix. My code made so far was this: LINHAS = 3 COLUNAS = 4 LINHA_ MatrizM = [] for i in…
-
0
votes3
answers3361
viewsMake list with input in python
Good morning, you guys. I need help to solve a part of the college exercise. The problem is relatively simple, but I’m having difficulties. My code is this: # Subprogramas def verifica_peso(pesos):…
-
0
votes2
answers249
viewsPython script does not generate chart as expected
My Python algorithm is running perfectly, I just can’t generate the graph! I couldn’t identify the error... What’s wrong? import matplotlib.pyplot as plt va=float(input('Digite o valor a ser…
-
0
votes2
answers69
viewsProgram with boolean expressions enters the if block every time
prefixes = "JKLMNOPQ" suffix = "ack" for letter in prefixes: if letter[0] == "Q"or"O": print(letter+"uack") continue print(letter+suffix) Expected response: Jack Kack Lack Mack Nack Ouack Pack Quack…
-
0
votes1
answer479
viewsHow to write a calendar in alphabetical order of Names using Python Ordereddict?
Nomes = [] Telefones = [] Endereços = [] Emails = [] Agenda = {"Nome": Nomes,"Telefone":Telefones,"Endereço":Endereços, "Email": Emails} entrada = "" print("Bem-vindo a nossa Agenda!!!!!") while…
-
0
votes0
answers118
viewsError trying to access ftp.debian.org using Python script: "Oserror: [Errno 101] Network is unreachable"
The script: import os from getpass import getpass #nao ecoa o que digita na tela! from ftplib import FTP # Variavél que determina se devemos usar o modo ativo # para FTP nonpassive = False # Nome do…
-
0
votes1
answer38
viewsHeroku Login Error: Cannot read Property 'body' of Undefined
Hello! I am getting the following error when trying to log in. heroku login heroku: Enter your login credentials Email: ########@gmailTypeError: Cannot read property 'body' of undefined at new…
-
0
votes1
answer66
viewsPython: Serialization of json namedtuple classes
import json from collection import namedtuple class Employee: def __init__(self, name, age): self.name = name self.age = age def tojson(self): return json.dumps(self.__dict__) Hello guys, I…
-
0
votes2
answers78
viewsRequest url wikipedia by date
Hello, a great friend made me this code, I am very new in python :` from bs4 import BeautifulSoup import requests url = "https://dumps.wikimedia.org/other/pageviews/2018/2018-04/" page_html =…
-
0
votes1
answer710
viewsCreate file without knowing directory? Python
It is known that it is possible to create a new file through Python through file_create = open(r'C:\Diretório\Diretório...\FileName', 'w'). However, it is necessary to indicate where this file will…
-
0
votes1
answer104
viewsHow do I print Side using end=" with the included Time Module
import time for i in range(0,10,+1): print(".", end="") time.sleep(1) I want to know how to print . sideways ex: ... During that time of 1 second... when I don’t use the end it works but printing…
-
0
votes1
answer149
viewsSelect the two highest values of a vector and add them up?
atletas = [] while True: nome = input("Nome: ") if not nome: break saltos = [] for i in range(3): salto = float(input("Distância {}:…
-
0
votes1
answer1779
viewsHow to grab and save many data entries in python?
Guys I’m starting to program and so far the data inputs were like this: dado_1 = str(input('Seu nome: ')) dado_2 = int(input('Sua idade: ')) dado_3 = str(input('Sexo: ')) But I was left with a…
-
0
votes1
answer692
viewsUse of the comma in Python
I’m having a problem understanding the difference between code 1 and code 2 (Fibonacci sequence). Apparently it looked the same, but the results they both print are distinct. Code 1 qtd_elementos =…
-
0
votes0
answers124
viewsProgram uses the threading module but I didn’t notice any parallelism in the execution. What’s wrong?
I made a script to decrease the quality of some mp3, calling the ffmpeg program through the subprocess module. I added Threads thinking of doing the process in parallel to multiple files at the same…
-
0
votes1
answer181
viewsPython strip() function malfunction
I have a list in a file, where each line has a user agent (with " at the beginning and end of each line), which is used in a later part of a program, to perform automated tests using Selenium. When…
-
0
votes2
answers218
viewsfor in range no flask template
I’m in doubt, the API I’m getting returns me two data types "ID" and "Title" are several id and title and I wanted to play this on my table in a "for" template. I wanted to know if what I did was…
-
0
votes1
answer1354
viewsHow to make a timer in Python 3?
I have to make a timer that counts x seconds, but does not stay in a loop waiting for time to pass, instead it should count the time and generate an event when closing the preset time count. I need…
-
0
votes1
answer375
viewsWhy doesn’t Pycharm show the methods of a class?
I want to know why Pycharm doesn’t show the methods of a class by pressing control + space. Normally IDE’S show all methods present in the class. In the image below I show what the IDE suggests of…
-
0
votes1
answer72
viewsswitching from one entry to the other when typing a word
Guys, help me with this, I have two entry and I need that when I type a word for example (Python) it changes from one entry to the other automatically from tkinter import *…
-
0
votes1
answer306
viewsError in requests with aiohttp in asyncio
import time import urllib.request import asyncio import aiohttp URL = 'https://api.github.com/events' MAX_CLIENTS = 10 def fetch_sync(pid): print('Fetch sync process {} started'.format(pid)) start =…
-
0
votes2
answers121
viewsSyntax error in basic Python 3 calculator
I was to program a basic calculator (add, divide, multiply, divide absolutely, find the rest of the division and power). The code is this : operando_1=input() operando=input() operando_2=input()…
-
0
votes3
answers783
viewsHow to input() stop after space instead of line break in Python3
I’m looking to capture several numbers on this graduate: 2 4 5 3 5 0 4 As a number of numbers undefined and without using an auxiliary list, I want to use only one variable for _ in range(0,n): num…
-
0
votes1
answer10618
viewsHow to print information in python table format?
I would like to print the results in table format as attached image. The code I’m doing is to literally reproduce the financing system above. Only when I go to test, they print one below the other…
python-3.xasked 6 years, 4 months ago Sandson Costa 509 -
0
votes1
answer61
viewsTkinter, how to use the same script in win and llinux without the window icon getting in the way
I’ve been writing some scripts in Win VS and when I switched to Linux, I came across the following problem: When I use an image as a window icon in Linux (which does not have it), the script does…
-
0
votes1
answer198
viewsPython asynchronous generators
With the introduction of the library asyncio, a new syntax was introduced to define coroutines in Python >= 3.5 and with it it it is possible to define asynchronous methods, asynchronous…
-
0
votes0
answers1009
viewsAttributeerror: 'Nonetype' Object has no attribute
Hello, I’m doing some testing with the framework Kivy and this error is being presented to me: AttributeError: 'NoneType' object has no attribute 'text' Well, follow the code Python: class…
-
0
votes0
answers40
viewsHow to leave the oceans blank in the Basemap?
The following code produces a map with a color scheme. I need the colors to stay only on the continents, leaving the oceans blank. How do I get this? excel file :…
-
0
votes2
answers75
viewsProgram that gives a secret number using bisection search
Create a program that gives a secret number using bisection search ! The user thinks of an integer between 0 (inclusive) and 100 (not included). The computer, using bisection search, gives a guess…
-
0
votes0
answers57
viewsPython - about asyncio
I started testing pynput with asyncio, but there’s one problem I can’t solve at all. My code: current = set() def on_press(key): if key == keyboard.Key.up: current.add(key) print('Y') if key ==…
-
0
votes3
answers5999
viewsInserted in a list of lists in python
I would like to fill in a list where each position of the same was a list. lista = [[], [], []] have an input: 44 45 49 70 27 73 92 97 95 and I would like to list the numbers so that the Index is…