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
answer2688
viewsUsing emojis in Python
Hello. I’m trying to use emojis in Python (version 3.7.3) but the image of emoji does not appear. I use Vscode (version 1.33.0) and installed the 'emoji' module via pip and import, but the image…
python-3.xasked 5 years, 6 months ago André 1 -
0
votes1
answer112
viewsCreate database and superusers automatically with Django
I developed a system with Python and Django. Now I would like to make it available on the web so that users can create accounts on the system, for this it would be necessary that each user has their…
-
0
votes1
answer39
viewsGet duplicate files in two lists
I have a report with links and I need to get duplicates, the problem is getting the two locations of file1.html files relatorio = ['~/file1.html', '~/pasta/file1.html', '~/file2.html'] Code: for x…
python-3.xasked 5 years, 6 months ago Igor Gabriel 530 -
0
votes2
answers335
viewsOperations sum and multiplication of integer numbers in Python list
The list code needs to receive 5 five numbers in reverse order, my code does it only that my code needs the 2nd number entered to be multiplied by 3 and the 4th number to be added by 5 (remembering…
-
0
votes0
answers94
viewsHow to perform unit test with unittest.mock for reading and writing files?
Good Night!!! This time my doubt is about unit tests. Come on. How can I test the section below in unittest.mock environment? def save_html_file(conteudo, filename, encoding='iso8859-1'): assert…
-
0
votes1
answer57
viewsSelect values from one column from other columns
I am trying to select only column values flightID where Depdelay and Arrdelay are larger than 15. I tried that: delay = data.loc[(data['ArrDelay'] > 15) & (data['DepDelay'] > 15),…
-
0
votes1
answer233
viewsDelete Intellij file permanently
I created a file File of the kind Text when it should be a file .py. After trying to rename the file to .py or delete it the IDE cannot identify the extension by not identifying my code. How do I…
-
0
votes1
answer70
viewsValueerror in Kfold from Scikit-Earn: My dataset has two classes! What’s going on?
I tried to cross-validate with a logistic regression using the Scikit-Learn . Follows the code: kf = KFold(n_splits=5, random_state=None, shuffle=False) kf.get_n_splits(previsores) for train_index,…
-
0
votes2
answers62
viewsComparison of lowest value in list
My problem seems to be simple but it’s bugging my head kkk, there it goes: When I compare my Values list to find the lowest value, it always returns 0, what happens sera? Follow Cód below. Obs:…
-
0
votes1
answer257
viewsProgram lock when executing function. Tkinter + Python3
It is the following I created a simple program to break md5 numeric, but the same lock when I click on descrypter and it only works again when it finds the hash, but it is locked until finding and…
-
0
votes2
answers353
viewsHow can I encrypt a user input text? giving error
from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.asymmetric import padding from…
-
0
votes1
answer98
viewsstr Object has no attribute 'Encrypt'
I made a program that generates a public key and another private key, serializes them and saves them in a .key. Dai tried to create another program to encrypt and decrypt a message with these two…
-
0
votes2
answers78
viewsCheck if directory 'B' is inside directory 'A'
I am developing a script that checks the last access date of each file within every tree of a chosen directory. Files over X days without access will be moved to another directory. As a precaution,…
-
0
votes0
answers37
viewsRecursion in python 3
def dobra(lista, l_dobro = []): if lista == []: return else: dobro = lista[0] * 2 l_dobro.append(dobro) dobra(lista[1:], l_dobro) lista = l_dobro return lista I’m trying to do this function using…
python-3.xasked 5 years, 6 months ago BRUNO FLAKS 11 -
0
votes1
answer132
viewsForce the implementation of a certain type of abstract method
In the Python it is possible to define classes abstratas and métodos abstratos slightly simply, for example: class Spam(ABC): @abstractmethod def grok(self): pass This class cannot be instantiated…
-
0
votes2
answers163
viewsChange class attributes from generic method
I have a class with many attributes and would like to be able to change these attributes from a generic method where you must pass the name of the attribute to be changed and the new value. class…
python-3.xasked 6 years ago CodexZombie 89 -
0
votes1
answer85
viewsFind the last matrix position
I’m making a game in pygame and need to know the last position of the matrix for the movement of enemies. It has to be according to the size of the matrix, that is, the last column and the first…
-
0
votes1
answer136
viewsTrasformar Datraframe in Dicionario
I ran a df from that dictionary: data = { 'Nomes': ['produto1','produto2'] 'Links': ['link1.html', 'link2.html'] 'Valores': ['R$00,00','R$00,00'] 'Tipos': ['brinquedo','aparelho'] } My doubt is how…
-
0
votes1
answer680
viewsDictionary with FOR loop in Python
While I study Python, time or other unpacking my own exercises. Only this time I 'Stopped' when I decided to do the code below. for c in range (3): bd = {} nome = input('Insira seu nome: ')…
python-3.xasked 5 years, 6 months ago Fernando Barros 39 -
0
votes1
answer588
viewsJavascript variable in Django template
Hello guys, good afternoon, I need to use a JS variable, being it the type Boolean in the Django template but I don’t know how to do it. Example of what I want to do: <!DOCTYPE html>…
-
0
votes1
answer330
viewsHow can I keep the private and publish key for later use? Since the program always generates different keys?
Well, I wish I could save the private key and publish it to use later to encrypt and if someone wants to decrypt my message, but every time the program generates a new key. How can I save the keys…
-
0
votes1
answer2959
viewsSave csv files to Python after making changes?
I am making some changes to multiple csv files at once, and would like to know how to save the output to a single file. import pandas as pd dataset =…
-
0
votes1
answer173
viewswhile (Cin >> str) An equivalent code in Python
Need to read multiple items without a fixed amount, in c++ just do while (Cin >> str) what would be an equivalent python code? has an answer in English to this same question here in the stack,…
-
0
votes1
answer141
viewsIs it possible to use Sqlite3 on Android using the Qpython3 app?
I’m trying to create a table: import sqlite3 def criar_tab_contato(conexao): cursor = conexao.cursor() sql = """ CREATE TABLE IF NOT EXISTS contato( nome text, telefone text, senha text ); """…
-
0
votes1
answer58
viewsWhat is the difference between the wraps and update_wrapper functions of the funtools module
In the module functools of bibliotaca padrão of Python there are two functions update_wrapper and wraps in the documentation of the function wraps we have: This is a convenience Function for…
-
0
votes1
answer293
viewsPython Error SQLACHEMY
Is giving an error when I try to connect to SQL SERVER database with SQLALCHEMY from sqlalchemy import create_engine, engine import pandas as pd engine =…
-
0
votes2
answers390
viewsOpen file with 2 clicks in a Python program
Hello. I’m creating a small Python notepad and wanted to know how I open a file. txt using it from 2 clicks in Windows Explorer?
-
0
votes1
answer712
viewsPython Glossary, library synonymous with package? Module synonymous with class?
I’m studying Python with video lessons, and the teachers use many synonyms that seem the same to me. In the case of these two terms are the same thing? Module by what I found right here would be…
-
0
votes1
answer83
viewsHow do I display an image according to a given Number and this number is by Random in python?
import numpy as np import matplotlib.pyplot as plt from PIL import Image import cv2 def showfig(image, ucmap): imgplot=plt.imshow(image, ucmap) img0 =…
-
0
votes3
answers241
viewsRemove elements from a Python Stop List
Basically I want to remove the elements from a second list based on the result of another list. I have two lists: lista_8 = ['', '', 'Preco', '', 'Preco', '', '', 'Preco'] lista_n = ['positivo',…
-
0
votes2
answers253
viewsK-Means Algorithm
Good morning, I will apply the K-Means in a given dataset, I already executed normal for fully numerical dataset, ex: Iris( vesicolor, setosa, virginica), but I came across a dataset with…
-
0
votes1
answer42
viewsOptimizing Data Output
Good morning: I made this code for an exercise. My question is: How can I optimize the outputs without having to do multiple prints. In this code I made for three exits. Only if it was for 10 exits…
python-3.xasked 5 years, 12 months ago Rodrigo Ferraz 309 -
0
votes0
answers42
viewsError installing mysqlclient on macOS with python 3
Error installing on macOS with python 3 pip3 install mysqlclient on macOS iMac-de-Qcx:~ gabrielveigalima$ pip3 install mysqlclient Collecting mysqlclient Using cached…
-
0
votes2
answers57
viewsProblem with list creation
I’m trying to create a function that has as input a list. The function calculates the number of characters of each component of the list and returns another list of numbers. After that would have to…
-
0
votes3
answers703
viewsHow to leave the program open in python
I made a program that reads a file but it reads and already closes, how to add a 'Press S to exit' for example and leave the print on the screen for longer? -below is the code…
-
0
votes2
answers37
viewsReturn a list of all strings in the file containing the searched string
I am trying to make a method that scans a list (my list comes from an external file that uses readlines() to assemble a list of strings) and compares it to a string passed by parameter. The feedback…
python-3.xasked 5 years, 11 months ago Anderson S. Taborga 23 -
0
votes2
answers32
viewsProgram performance in order of module loading
Someone would tell me if there is a relevant difference in the performance of a program (in this case, done in Python) when importing all modules to be used from the beginning of the code instead of…
-
0
votes2
answers80
viewsexec with n does not work
I’m trying to use the function exec in a code that has \n, but it seems that this function does not support \n a = ''' open('test.txt', 'a').write('Hello, world\n') ''' exec(a) Error: SyntaxError:…
-
0
votes1
answer68
viewsFormatting of Python File
Hello, I’m a beginner in Python and I’m working with natural language processing. When processing a text and separating the sentences, I want to write this way in the << SENTENCE >>…
-
0
votes0
answers161
viewsReceive a keyboard URL and drip it into Python
Receives a URL typed via keyboard Ping the respective URL Returns the ip (if any) of the entered URL Ex.: Type a URL: www.google.com Pinging www.google.com [172.217.162.164] with 32 bytes of data:…
-
0
votes1
answer342
viewsDoubt how to scrape data like Python using Beautifulsoup <Table>
I’m beginner and I’m trying to get a table of the website of the portal of transparency, but I’m not getting only comes to tag with no data. When I open the developer tool I visualize the data I…
-
0
votes1
answer38
viewsreceive an object in a method of the same type as the method class
I’m passing a java code to python and came across it(cutting a few parts) public class TreeNode { public TreeNode(TreeNode pai) { how do I receive the father of the type Treenode in python? class…
-
0
votes3
answers693
viewsI can’t make the sum of the first 100 prime numbers, where am I wrong?
#python3.7 cont = 0 cont_100 = 0 primos = 0 num = 1 soma = 0 while True: primos += 1 while primos != num: if primos % num == 0: num += 1 cont += 1 if cont == 2: soma += primos num = 1 cont_100 += 1…
-
0
votes1
answer828
viewsHow to relate a model to another model in Django 2
I’m making a system in which I need to show data that is registered in another Model, which in this case is the Category field that is in the Model Items and when showing it, the user would select…
-
0
votes1
answer102
viewsIs that a Python 3.6 bug?
The code below is a demonstration of what I’m trying to do: I have a vector (todos) in which elements are added. The second vector (alguns) also receives new elements, and I need to know if the…
-
0
votes1
answer223
viewsError: Deploy Python Heroku - Runtime (python-3.4.0) is not available
Personal, all right. Someone can help me solve the following problem: I’m making an application in Django and now I’m in the process of uploading to the server. I’ll send it to Heroku. I performed…
-
0
votes0
answers329
viewsModulenotfounderror: No module named 'requests_html'
I’m trying to use the module requests-html however in Mac OS 10.14, it presents this error both when trying to install with Pip and with easy_install it presents the error saying that this module…
-
0
votes2
answers199
viewsI’m trying to use an asynchronous function in python-3, but it’s giving error
Error: Warning (from warnings module): File "C:\Users\tiago.pereira\Desktop\python\kivy\kivy_teste.py", line 43 pythoncom.PumpMessages() RuntimeWarning: coroutine 'Keyboard' was never awaited…
-
0
votes4
answers2181
viewsCheck file extensions in Python
I need to check the extensions of all files inside a folder, for example: Pasta: arquivo1.txt arquivo2.wav arquivo3.mp3 arquivo4.mp3 arquivo5.mp3 arquivo6.txt output: txt, wav, mp3 Does anyone know…
-
0
votes1
answer546
viewsSQLITE query returning value outside of query rule
I made a program, in python language, that creates a database SQLITE which stores information about a number of closet doors. The information stored are: id (port identification), size (PQ = small,…