Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
0
votes1
answer180
viewsProblem with hashlib
I have a problem to use the python hashlib, because I am comparing the hashs generated with the line below, with the hashs generated on the site : 'http://temp.crypo.com/sha512.htm', but when…
-
0
votes1
answer239
viewsPython2.7 with Opencv 3.3.0 - Videocapture problem
I’m running Opencv 3.3.0. with Python 2.7 on a Windows 7 Professional x64 machine, and when I run the code below, falls in the prints "Something went wrong" and "Finished ..." import cv2 capture =…
-
0
votes2
answers335
viewsHow to add multiple dictionaries using pickle to save to txt
I’m having trouble saving a file using the pickle module, every time I run the program it rewrites over the existing dictionary. I tried to use the shelve to sub-post but I didn’t get a hit. Below…
-
0
votes0
answers29
viewsDatatables + web2py
I have a table that shows results of a database search and I use the Datatables plugin to mount the pagination. The problem is this: if you go over 500 records the business gets slow (Virtually all…
-
0
votes1
answer9605
viewsExporting data in json or txt, in python?
I need help to learn how to export data from an object. At first I need to export in type "txt" and/or "json", but I could not succeed in either. The code: #coding = utf-8 import json . . . def…
-
0
votes1
answer2149
viewsList files from a folder using.listdir
I want to list the files of a folder using the os.listdir in Python but returns nothing. The code I made: import os def rename_files(): # (1) obter nomes de arquivos de uma pasta file_list =…
pythonasked 7 years ago Anselmo Alves 3 -
0
votes1
answer130
viewsIndex of tuples in a list - python
Organisation of information in the file (City, City, Distance) import csv with open('cidades.csv', 'r') as f: list1 = [tuple(line.values()) for line in csv.DictReader(f)] for i in list1:…
-
0
votes1
answer244
viewsArray and Mimetext - Python
Why it is not possible to use Array to add inside a Mimetext type variable (msg = Mimetext(body, 'html'))? Explain: for row in cursor.fetchall(): for owner in cursor.execute("select * from orcam…
pythonasked 7 years, 2 months ago user2287892 57 -
0
votes1
answer32
viewsVerificaciones periodicas Django
How could I create a loop, thread or anything that my webapp periodically checks every 5 minutes the database and deletes entries that are "expired". I did some research, but I couldn’t find…
-
0
votes1
answer1443
viewsFlask connection between two machines
I have a Client-Server application in Flask, running the two files on the same machine the connection works perfectly, but when I try to run the client on a different machine, the connection is not…
-
0
votes1
answer167
viewsFind more than one standard re python?
I’m trying to rename files using regex in python, with only one standard works: def new_string(pattern): text = pattern.group().lower() renturn "{}_{}".format(text[0], text[1]) regex =…
-
0
votes0
answers2315
viewsHow to download a file with Python?
This site has several links that open Pdfs, in the locations of "Entire content": http://www.camara.gov.br/proposicoesWeb/prop_emendas?idProposicao=2122076&subst=0 In Python 3 I wrote this code…
-
0
votes2
answers878
viewsGet data from Django view
When registering a new user he chooses which group he is part of through a select. Each group has a responsible person, how do I get the email of this responsible person to send an access request…
-
0
votes1
answer1394
viewsHow to improve a bar graph whose values are very close in Python?
I am drawing the bar graph using the following Python code: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y…
-
0
votes1
answer36
viewsConnection only works with manually set values
I have a Socket class that is working normally this way: class Socket(): __ffChatSocket = "" __meuTelefone = "" __WhatsappAPI = "" __dest = () def __init__(self, telefone, WhatsappAPI): ip =…
-
0
votes1
answer29
viewsNaïve Bayes execution error using Spark
When I change the input file (by default: sample_svm_data.txt), on the other also containing numerical attributes separated by spaces, the following error occurs: File…
-
0
votes2
answers36
viewsSeparating using + signal while reading user data
Excuse me for the basic question. I just don’t understand when we have to use the + in the Input. Follow the example of a command below. Why does my code not work when I put the str(i) between…
pythonasked 7 years ago Pedro Henrique Santos 19 -
0
votes1
answer128
viewsHow to isolate metadata with pdfminer?
I wrote this code in Python 3 to read the metadata of a PDF: >>> from pdfminer.pdfparser import PDFParser >>> from pdfminer.pdfdocument import PDFDocument >>> fp =…
-
0
votes1
answer1772
viewsHow to use functions that are in a different file? - Python
I’m having a problem using functions that are in a different file than where I’m calling these functions. Basically my project is organized as follows: Lista_I (Pacote Contendo os Arquivos)…
-
0
votes1
answer1202
viewsIs there a size limit on the writerow of csv?
I will create a CSV of 1,341 lines (with header). In Python 3 I used csv commands, but the file created has 1,282 lines The line data is extracted from 1,340 Pdfs, from the metadata. I created a…
-
0
votes0
answers202
viewsCreate a table in Django’s User models!
Well, I would like to create a column in the User models table of Django, because I would like to get the password before Django turns into sha256, because I want to display it in the browser…
-
0
votes2
answers111
viewsSeparate input value and expected value in pytest.mark.parametrize
How do I separate the parametrize, the input from the expected @pytest.mark.parametrize('entrada, esperado', [(1,0,0,), (1,0,) ]) def testa_raizes(entrada, esperado): assert…
-
0
votes1
answer65
viewsHow to work with multiple codec’s in pdf?
I have a set of over 1,000 Pdfs that I need to extract the metadata. The problem is that Pdfs have different codecs. The first example worked, I used utf8. The second example gave error. It is…
-
0
votes1
answer118
viewsI’m trying to get my chart started from position 0 using hist()
Using USAGE_PLOT became easy to do but I want to do and learn how to use Hist. the same way it is in the image below where it was used usage_plot(trip_data, 'duration', ['duration < 60'],…
-
0
votes1
answer655
viewsI am unable to open another Pyqt5 form
I can’t seem to make the other window in my file appear. Code: # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'testando.ui' # # Created by: PyQt5 UI code generator 5.9…
-
0
votes1
answer510
viewsCounter of recursion solutions
Hi, I made a recursive Sudoku program, it’s working fine, but I’d like to add a solution counter, I’ve tried numerous code changes that would make it possible, but it didn’t work, finally I tried a…
-
0
votes0
answers61
viewsString to float conversion error
I need to input this function and this value to make the calculation but this conversion error #1ª tentativa x0 = float(input('valor: ')) fx = float(input('função')) #Exemplo: (x0**4)^2-9*x0…
-
0
votes1
answer31
viewsHow to differentiate 2 inputs created with for loop and perform operations between them
How do I sum the 2 values typed by the user? My code: for c in range(0, 2): n = int(input('Digite um valor:')) How to differentiate the first value of the second to do operations as sum and…
pythonasked 7 years ago Lucas Souza 567 -
0
votes2
answers474
viewsPrint of the result of a ternary operator
How to display the output of a ternary operation next to a string, using Python? I intend to check if the size of the name typed is larger than "Braga". For this condition, I want to use the ternary…
-
0
votes0
answers81
viewsName file with sql query data
Hello, I need to name each file created by the script with a data from a single column of my data bank. Follows the code: for index, source in zip(list(range(0, len(self.sources))), self.sources):…
-
0
votes1
answer330
viewsraise Keyerror(key) from None Keyerror: 'TCL_LIB (.Py to Exe)
I am trying to convert a Python script to exe to run on Windows machines, I have the following code in setup.py import sys from cx_Freeze import setup, Executable import subprocess import socket…
pythonasked 7 years, 2 months ago Vitor Couto 158 -
0
votes1
answer822
viewsPython CSV How to rewrite only one line of the file?
I have a row that stores within the file the following columns: ID Nome Telefone Descrição DataEntrada HoraEntrada The ID is basically the line number and it is through it that I will seek to know…
-
0
votes1
answer187
viewsFinishing a python project
I have some questions about the projects created in python. If I create a program and need to pass it to someone else, I will need the other computer to have python installed and with all the libs I…
-
0
votes1
answer301
viewsHow to save information like pprint to a txt file
I am creating a function to generate a log file: def setLog(msg): file = open(nome_arquivo, adicionar_informacao) if type(msg) == str: msg_log = msg.encode('utf-8'); else: try: msg_log =…
-
0
votes1
answer3728
viewsLogarithmic Scale Graph with Python
Initially I created a Values X tempo (Unix Time) chart with the following code: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import…
-
0
votes1
answer272
viewsSolution for Python Unisex Bathroom Problem
Suppose you are at a party in the Republic Calamity Public that has only one bathroom with n boxes, where box is a compartment with a toilet. The republic rule says that the bathroom can be used by…
-
0
votes0
answers53
viewsMessage Value error
Good afternoon, I got an error message from Coul operands not be broadcast Together with shapes (256,) (268,) image shows the error the code is as follows:: import RPi.GPIO as GPIO from lib_nrf24…
pythonasked 7 years, 1 month ago Sergio Nunes 351 -
0
votes1
answer159
viewserror running kivy designer, No module named 'designer'?
How to resolve this error in kivy designer ? [! [insert image description here][2][2]…
-
0
votes2
answers1177
viewsSaves browser status or cookies using Selenium
I’m doing tests using the web Whatsapp, so every time I run Selenium, read the qr code and start the tests, and I have to do this every time, I’d like to know if there’s a way to save the state of…
-
0
votes1
answer1720
viewsRead data from an Sqlite 3 database in Python
I’m starting in Python and database and I have three questions! For example, inside my database I have a "name" column. Just to illustrate, say I want to take the contents of the "name" column…
-
0
votes2
answers1353
viewsNo module named 'urls' in Django
I’m studying about URL division in Django and I can’t direct my main url file to high school. Tracking: Traceback (most recent call last): File…
-
0
votes1
answer819
viewsInvalid syntax message without any apparent error
I am trying to rename a folder that has a set of files, I want to remove all digits of the names of the files. But when I try to run the code the error message appears: "invalid syntax", pointing…
-
0
votes1
answer509
viewsWhat is the best way to scrape the Datasus website in Python?
The link is this: http://tabnet.datasus.gov.br/cgi/tabcgi.exe?sih/cnv/nrbr.def I’m trying to send a POST through requests with a dictionary containing the categories I want, but then the URL remains…
-
0
votes1
answer113
viewsGPIO Pins Rpi 3 Python
I’m starting with a project with my rpi 3 that concise in using engines connected to the rpi3 gpio pins! In my code there is some error connected in the mode of the pins, but I do not know how to…
-
0
votes1
answer49
viewsTurning a python function into a PHP function
Someone would know how to turn this function that is in python to a php function? def createSignature(clientId, apiKey, privateKey, nonce): message = str(nonce) + str(clientId) + apiKey signature =…
-
0
votes0
answers197
viewsHow to send multiple commands to a remote server using python
How can I send multiple commands to a remote server using python? I had to learn python for reasons of study, so I decided to try to automate the console information collection. I’m trying to use…
pythonasked 7 years, 1 month ago Samuel Santiago 1 -
0
votes1
answer531
viewsSqlite - Python - refer to table column in a loop
I’m doing a script in Python accessing Sqlite database. I made a loop for but don’t know how to get the value of a column in the table. Take the example: cursor2 = cnx.cursor()…
-
0
votes1
answer2903
viewsAdjust Tkinter window and widjets according to screen resolution
Hi, I’m developing a python GUI with Tkinter. I’m trying to get the widgets setup I set up to fit the monitor resolution. I applied the following code. janela = tk.Tk() lado, cima =…
-
0
votes0
answers213
viewsAttributeerror: 'Nonetype' Object has no attribute 'fileno'
Good morning! I’m starting my study in python-pandas, and I’m having a problem that looks like simple resolution. But not for me. Yet. I’m following this tutorial:…
-
0
votes0
answers57
viewsError in converting Matlab to python
I intend to convert the following function into Python: Função Matlab cn = reshape(repmat(sn, n_rep, 1), 1,[]); resultado matlab cn = Columns 1 through 23 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 1…