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
-
1
votes1
answer382
viewsPython: select checkbox in an orderly way
I have a list containing hundreds of data in the format [ '5008489', 'Órgão: MPF', 'PROCEDIMENTO DO JUIZADO ESPECIAL', 'CPF', <selenium.webdriver.remote.webelement.WebElement…
python checkbox selenium selenium-webdriver web-scrapingasked 7 years, 2 months ago Bergo de Almeida 181 -
1
votes1
answer95
viewsReverse loop Selenium python
I’m trying to do a reverse loop on my list of li in Lenium and it’s not rolling. I’ve tried one reversed in the list but error. I want to loop the last one li until the first. For example, in the…
-
1
votes2
answers400
viewsWhat are the statements placed before strings?
In python, I observed that these "indications" were placed in two cases, first in strings before passing through a hash algorithm, e.g.: import hashlib m = hashlib.sha256() m.update(b"Nobody…
-
1
votes1
answer848
viewsDisplay only hours, minutes and seconds on a graph whose input is in Unix time
Be the Python code that generates a bar graph: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] with…
-
1
votes2
answers875
viewsDecode data in Base64
I am working with metadata of an image extracted in Json format. One of these data is a binary string Base64. I read in documentation that these values are 16 bits. Is there any way to decode them…
-
1
votes1
answer274
viewsHelp training Opencv
In a process of creating a haarcascade, I performed the procedures according to the tutorials of the Opencv library and arrived at the result of a vector with the number of 70 positive images named…
-
1
votes1
answer1363
viewsimport openpyxl / Modulenotfounderror: No module named 'openpyxl'
When I type in IDLE, import openpyxl, the following error message appears: Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> import openpyxl ModuleNotFoundError:…
-
1
votes1
answer66
viewsProblem with argument substitution in function
I’m having a problem with the arguments I pass in the function below, I’m trying to pass the argument sha512 for hash_type, so that the code within the function is replaced, and so hash_target would…
-
1
votes1
answer554
viewsProblem with reading python files
What is the difference between, make python open and read a file, to pass the read result between áspas? For when I open a file, it contains only the word test and I pass this reading result by a…
-
1
votes0
answers77
viewsHow to use f2py using more than one . F90 file and using dassl. f?
I’m a beginner in F2PY and I’m trying to use it in a very complex Fortran program that has several subroutines in separate files and one of them is dassl.f. I believe my problem is with it. Are…
-
1
votes2
answers368
viewsDjango Rest compare user 'sector' id with publication 'sector' id
Well, I’m messing with an API and I want it to return content only when the user sector is equal to the publishing sector API for publications: The user has a sector field also equal to this, and…
-
1
votes1
answer54
viewsThe code is right, but could someone tell me how True and False works in detail in this question (step-by-step)?
"Make a program that, when filling a list with 8 integers, already stores them increasingly. Show the resulting list each time a value is stored" lista = [] for x in range(8): n = int(input("Digite…
-
1
votes1
answer982
viewsError generating matplotlib graph
I am new to Python and I am having difficulty with my algorithm, the function of it is to check words in a set of files in PDF format and analyze the recurrence of each word generating with this…
-
1
votes0
answers490
viewsHow to create streaming service with python and Django
I have the purpose of creating a video streaming service, the project is in python and Django. How do I make such a service available? Python 2.7 and Django 1.10 usage. I only found old material!…
-
1
votes2
answers943
viewsUse of if __name__=='__main__'. Why is the class not instantiated?
There is little time that I am using Python and there are some things that I still get confused, my doubt is in this code: import unittest from selenium import webdriver from…
pythonasked 7 years, 2 months ago Wictor Chaves 8,445 -
1
votes1
answer1294
viewsIs it possible to collect html source code using python?
I would like something in python, some library that could access the site and get its source code (HTML). Example: Talsite.com <h1>hello</h1> Is it possible for python to log into…
-
1
votes1
answer48
viewsHow to change is_staff when I click href?
I have a table with users in HTML with id and name, by default when register a person it comes with is_staff=False. I want when I click the Authorize link to switch to is_staff=True, how do I do…
-
1
votes1
answer95
viewsError in Python2
I’m practicing using Python 2, but I don’t know the reason for this error. Follow below my code with the error. And numpy and scipy are installed, because when I give the import no more error…
-
1
votes2
answers204
viewsPrintar 2 interlaced strings
How do I print 2 interlaced strings (I don’t know if that’s what it’s called)? For example: string1='aovces' string2='m o' so that in the print "I love you guys" in the case, interspersing each…
-
1
votes2
answers1795
viewsHow to create a PDF from Dictionary data extracted from a . txt (Python) file
I have a dict() with string data extracted from a arquivo.txt. dic = {} dic[valor[0]] = valor[1] print(dic) >>> dic = {'Almir': 44, 'Ana': 36 ....} I would like to save organized in PDF as…
-
1
votes1
answer6005
viewsTransform all elements of a list into floats
That’s the code I wrote. n_alunos=input('') x=0 idades=[] alturas=[] while x != n_alunos: x+=1 n=raw_input('') a=n.split(" ") idades.append(a[0]) alturas.append(a[1]) How to transform the elements…
-
1
votes1
answer647
viewsProblems with the While Repetition Structure
I’m trying to create a program based on the repetition structure while, but the loop does not end. sexo = str(input('Digite seu sexo:')) if sexo != 'M' or sexo != 'F': while sexo != 'M' or sexo !=…
-
1
votes0
answers257
viewsPackage of graphical interface
I want to start a great project to start learning better Python and some other concepts, I have basic knowledge about the language, I’ve done some scripts, mainly add-ons to the software Blender.…
-
1
votes1
answer144
viewsError to access parent class method
Traceback (Most recent call last): File "C:/udemypy/Basico/classes/heranca/ex2/funcionario.py", line 20, in print(gf.getBonificacao()) File "C:/udemypy/Basico/classes/heranca/ex2/funcio.py", line…
pythonasked 7 years, 2 months ago Weliton Figueiredo 147 -
1
votes0
answers246
viewsSending email picking up data FK Django
I have group and profile, in my register the person chooses the group and this group has the responsavel_id, I want to pick up and send a confirmation email to the responsible of that group that the…
-
1
votes1
answer613
viewsLogin to Django
I have a login page, I need to check who’s logging in, Example: if you are responsible for group A, direct to the page with all users of group A, if you are responsible for group B, to the page of…
-
1
votes2
answers107
viewsEstimating the response time of a server using Python or regex
I created a virtualized environment with an Apache server (running in Debian) and several attacking machines running Debian as well. Vmware Workstation was used. Server IP: 192.168.91.5 I have dump…
-
1
votes2
answers2960
viewsElements in common between lists
How do I compare elements from 2 lists, and return the amount of elements in common ? For example: a=[1, 2, 3, 4, 5] b=[6, 7, 8, 9, 10, 1, 2, 11, 22] This should return 2, because there are only 2…
-
1
votes1
answer647
viewsSelect data from a spreadsheet
I read data from a spreadsheet using Python 3 libraries (xlrd / xlsxwriter / Pandas and Numpy). This spreadsheet has in the rows questions of the survey and in the columns the areas that answered…
-
1
votes1
answer951
viewsFlask relationship of sqlalchemy tables
Eae personal! I come to ask a force, I have a problem to accomplish the construction of the object to create the relationship of the tables. I have a driver’s table and another passenger and another…
-
1
votes1
answer138
viewsDoubts about functions
This my code simulates banking operations using functions, but I am not able to return the function values, when I Seto the value of the Return in a variable it calls the whole function. In the…
-
1
votes1
answer501
viewsLegacy of Templates not working
I’m trying to create blocks within my base template (index.html), but apparently the block is not used. index.html {% load static %} <!DOCTYPE html> <html lang="pt-br"> <head>…
-
1
votes0
answers728
viewsGet modal data from Django
I have a list of customers on the screen of the responsible person, in case he presses to deny the client, opens a modal with the field Reason for him to fill. I want to take what was typed in this…
-
1
votes2
answers508
viewsMost Important Attributes in Random Forest Classifier
Good afternoon guys, I wonder if you have to return a percentage of each attribute used in training Random Forest Classifier, to show which attributes are the most deterministic.
-
1
votes1
answer131
viewsHow to open different web pages using while
I would like the program to perform the repetition of a command 3 times: wait 10 seconds to open a web page. For this repetition to occur I set the code below: import time import webbrowser…
-
1
votes1
answer168
viewsPython constructor with **kwargs
I would like to know if the use of **kwargs in a constructor is the best alternative or if there is a better path for similar cases to the one below: class Duvida(object): def __init__(self,…
-
1
votes1
answer355
viewsError in sql-Insert command when passing a variable as parameter (python 3)
I am trying to pass my "table" variable to the mysql command, but it is returning an error (of sql) during execution. What am I missing? Here I created the table variable table = input('Table name:…
-
1
votes1
answer495
viewsMultiprocessing with python infinite loop functions
I’m doing a graphical interface with Gtk in python, and I have a serial script that keeps sending and receiving data from a microcontrolled system. The serial script is in an infinite loop (while…
-
1
votes1
answer819
viewsPython - Dividing words delimited by blank space or square bracket
I have a string with several words inside, some words are separated by space, but some are compound words and are protected by square brackets. EX: string = "Goiânia Vitória Brasília [Campo Grande]…
-
1
votes1
answer75
viewsProblem with numpy matrix
I’m having a problem using NUMPY. It has an array testeSolucao, of that kind <class 'numpy.matrixlib.defmatrix.matrix'>, And I need to get the least amount of it, but I can’t. At first I…
-
1
votes2
answers187
viewsHow to avoid repeating code?
I have a Python 3 script that tries to be a chatbot, where there are several if and elses which are used based on what the user responds to. The problem is that in all functions, like get_name() or…
pythonasked 7 years, 1 month ago Lucas Amorim 13 -
1
votes1
answer350
viewsscript search - python
The problem is I can’t separate the arquivo_novo of /root/arquivo_novo, as indicated below. I only need the "new file" to be able to enter the LOOP IF and the system returns /root/arquivo_novo and…
-
1
votes1
answer45
viewsId from the inserted email
I have a form with only the email label for the user to fill. If the email already exists I want to redirect it to the edit page. How do I get the user id from the email he typed? I did a test as…
-
1
votes0
answers174
viewsDownload html from python post login screen
Hello, I’m wondering if there is any way to get the url of a site, the password and login strings and simulate a clone to go to the next page (already logged in) and download its source code. Note:…
-
1
votes2
answers3598
viewsImages with Django - exhibition and Static
I’m a beginner in Django and I’m developing a simple blog. I know that the configuration of static files needs to be different for the development and production environment, but I always get caught…
-
1
votes3
answers4541
viewsSyntax error in Python code. What is it?
print("**************") print("Seja Bem Vindo") print("**************") numero_secreto = 65 chute = input("Digite um numero:") print("Você digitou: ",chute) if numero_secreto == chute print("você…
-
1
votes3
answers568
viewsMemoryerror on the pandas
Hello I am using the pandas merge command in python3: ibama_doadores_orig = pd.merge(eleitos_d_s_doadores, ibama, left_on='CPF_CNPJ_doador_originario_limpo', right_on='CPF_CNPJ_limpo') But a message…
-
1
votes0
answers501
viewsUpload images to Django
How to upload more than 1 image in Django Admin ? this is my mode : from django.db import models class Imovel(models.Model): titulo = models.CharField('Titulo', max_length=200, blank=False) slug =…
-
1
votes1
answer2078
viewsxlrd opens files in xls format?
excuse my ignorance on the subject, but I’m developing a Python script that reads Excel files to get certain information on these, and for that I’m using xlrd, I was wondering if xlrd is able to…
-
1
votes1
answer1939
viewsHow to open, read the file and save in a list of lists the contents of the file using Python
I have a list of paths txt files. With the read() function, I can save the entire contents of the file within a list where each word is stored at a list position. However as I intend to read 3 files…