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
answer56
viewsIntellisense python
I’m learning to program in Python and is recurring in the following situation (this occurs in FDI pycharm, Atom and Spyder): I imported the matplotlib as follows: import matplotlib.pyplot as plt…
-
0
votes1
answer87
viewsMultiple ui’s on the same Qmainwindow
I am trying to put two Qwidgets imported from ui files, however none appears, problem that does not occur when I enter only one. # -*- coding: utf-8 -*- import sys from PySide2.QtUiTools import *…
-
0
votes1
answer91
viewsI’m new to programming, how do I get out of sequential foma returns?
ano = input() a= ano.split() def contaDigitos(): for x in a: s= len(x) if s !=4: return "Ano invalido" else: return x def ehBissexto(): for x in a: x= int(x) if x % 4==0 and x %100!=0: if x>…
-
0
votes1
answer183
viewsQwidget class inside Qmainwindow class
I have the following code: # -*- coding: utf-8 -*- import sys from PyQt5.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QPushButton from PyQt5.QtWidgets import QSpacerItem, QLabel, QComboBox…
-
0
votes1
answer486
viewsDjango.contrib.auth import views || Login Authentication and url redirection
I’m trying to use Django’s libraries to check if the user is logged in, and only then can he log into the pages of my website. I’m coding according to some Internet classes, in his example was…
-
0
votes1
answer301
viewsRecover link when using click() from Python
I need to recover the url address when clicking on the link, I am using Selenium with chrome_options.add_argument("--headless") My current code: links =…
-
0
votes1
answer56
viewsHow can I replace this regular expression using Beautiful Soup
Currently I use this expression to extract everything below the tag <b> until I find another tag <b>: blocks = re.findall(r'<b>.+?<b>', str(element)) How can I do the same…
-
0
votes1
answer501
views -
0
votes2
answers84
viewshow to get the element from a list based on another list
I wanted to remove a doubt I’m having with lists in Python, follow an example below: lista1 = [2, -1 , 4, -5] lista2 = [1, 2, 4, 9] As long as the list element is > 0, I need to take the list…
-
0
votes0
answers33
viewsWhat are Python commands with underscore at the beginning and end?
I realize that some scripts in Python have expressions with commands like this: __name__ == “__main__”' __str__,__repr__ self.__class__ self.__dict__ What are these commands that start and end with…
-
0
votes1
answer846
viewsTake print screen when error occurs on Selenium Webdriver
I have a mini bot made in Python that does the scraping of data from Direct Treasure, in short it logs into my account, goes in the statement takes this data and returns a json, which within my…
-
0
votes1
answer117
viewsKeras Model for Tensorflow
I am learning Tensorflow and am trying to pass a Deep Learning model in Keras to Tensorflow, however, I am having difficulties. Model Keras: model = Sequential()…
-
0
votes5
answers714
viewsI want to turn a text into a list of dictionaries
I’m making a bot in python for twitter that posts news about Latin America, at the time of making the system that detects whether a news is new or not, I will save the news that has already been…
-
0
votes1
answer781
viewsHow to change the shape of a cell with Pyhton and Openpyxl?
All right with you? I am working with the transposition of databases from one Excel file to the other, and when transposing the values to another file, I would like to set the types of values of…
-
0
votes1
answer126
viewsPython sum recursion
Well, I’m doing this code that’s meant to add and print recursively. The variable le is the amount of times I want, which would be an accountant to at the end inform the sum of the numbers written…
pythonasked 5 years ago Junior Bgdk 1 -
0
votes1
answer502
viewsQual é a diferença entre os.path.dirname(os.path.abspath(__file__)) e os.path.abspath(os.path.dirname(__file__))
The two seem to return exactly the same. Inclusive, os.path.dirname(__file__) returns the same too.
-
0
votes3
answers613
viewsShow python position of prime only
Read 10 integers and store them in a vector. Then type the elements that are prime and their respective positions in the vector vetor=[] for c in range(3): n = int(input("Digite um número para…
-
0
votes1
answer139
viewsError with date time
Guys I’m trying to run my code, I’m having the following error: Typeerror: 'datetime.date' Object is not subscriptable How do I fix it? follow my code below: def making_date(self, *args, **kwargs):…
-
0
votes1
answer767
viewsError: Userwarning: Data Validation Extension is not supported and will be Removed
Beginner in the world of programming, I’m trying to make a script that I pull information from API of the recipe and play in a excel, but I can’t write on excel due to error, when I put…
pythonasked 5 years, 9 months ago Carlos Polli 11 -
0
votes1
answer577
viewsChatterbot installation error (python)
Every time I try to install Chatterbot either through Pip or pip3 it gives a giant error. I saw in some questions that when installing python 64bits it would solve, I did it but nothing. Even,…
-
0
votes1
answer1861
viewsHow to solve the None problem in PYTHON
For example I have this program: def bissexto (inicio,fim): """Diz quais são os anos bissextos""" for i in range (inicio,fim+1): if(i %4==0 and i %100!=0) or i %400==0: print(i,"- Bissexto") else:…
-
0
votes1
answer654
viewsHow to make a chart from a python dictionary
I am wanting to make a graph in python pulling information from a dictionary. In my case is the following, I have an initial and final date, I made the difference between the two. If the difference…
-
0
votes1
answer137
viewsLambda function to return higher value from a list of dictionaries
Good evening. Could someone explain to me how the lambda function below works? I’m not understanding why it returns the highest value in the dictionary. Another thing I’d like to know, the 'x' is…
-
0
votes1
answer436
views3D Python Graphics
I have 3 arrays, from the arrays I must draw a 3D graphic. I have tried several ways but I could not. I believe I am not creating the data frames correctly. I’m trying to do it this way: x =…
-
0
votes2
answers216
viewsFilter objects in DJANGO - published_date__lte
I’m following a tutorial for modeling a BLOG through the DJANGO . In one of the processes, I create an object with the site posts and order them through the publication date: def post_list(request):…
-
0
votes1
answer418
viewsPersonalized login in Django, what is the best way to improve?
At the moment I need to log in django.admin and login that I myself have created in a models.py | Class Pessoa. In this way it is not functional, because the admin needs to be logged in for a normal…
-
0
votes1
answer25
viewsTrying to lambda the dataset?
I’m trying to apply this function to the dataset: number_outliers = (df2 < (Q1 - 1.5 * IQR)) | (df2 > (Q3 + 1.5 * IQR)) df2.apply(((lambda x:df2[~((df2 < (Q1 - 1.5 * IQR)) | (df2 > (Q3 +…
-
0
votes0
answers81
viewsView.py class in Django
I’m trying to develop a quiz with Django, in my logic I created a class in view.py, but now I don’t know how to reference the methods of this class in the url.py py views. from django.http import…
-
0
votes2
answers53
viewsLibrary import
A while ago I had a question about importing libraries (here: Why should we import Messagebox explicitly into Tkinter even importing with the asterisk?) and explained to me that, in that particular…
-
0
votes1
answer104
viewsHow do I add an image to a python script using Tkinter
I’m trying to add an image to a program with the following code: from tkinter import * root = Tk() imagem = PhotoImage(file="imagem") lb = Label(root, imagem=imagem) lb.place(x = 0, y = 20)…
-
0
votes2
answers350
viewsRecursive algorithm for calculating arithmetic mean
I am making an algorithm that has to calculate the average values of a list, but with what I did does not present the correct result. The sum works, but when it comes to dividing, no. def…
-
0
votes1
answer28
viewsGeneric relationship between model Logentry
Someone has worked with Auditlog on Django ? Documentation of Django Auditlog Let’s say I have this model: class Cadastro(models.Model): nome = models..TextField() auditlog.register(Cadastro) I…
-
0
votes0
answers67
viewsError executing Python code.Am I doing something wrong or is it a problem in my IDLE?
I’m a beginner in Python and just when I went to test the Turtle module for the first time it ran normally when I was typing the commands and running at each line. However, when I saved the same…
-
0
votes1
answer130
viewsInsert Alternatives into a Model in Django
Good evening. I’m a beginner in Django, I’m trying to make a simple platform, kind of a quiz and I’m having a question. I have the following class: class Questao(models.Model): subdominio =…
-
0
votes1
answer707
viewsIs there any way to compare all item values in a python dictionary?
Is there any way to compare all item values in a dictionary? For example: a = {'valor1': 4, 'valor2': 5, 'valor3': 4} b = {'valor1': 2, 'valor2': 2, 'valor3': 8} if a['valor1']*2<b['valor1']:…
-
0
votes3
answers258
viewsTkinter: Tk() not found
When trying to call the function Tk(), it is not recognized by showing the following message: Nameerror: name 'Tk' is not defined I’m trying to start the following code: from tkinter import * root =…
-
0
votes1
answer78
viewsWebscrapping Soup + python export to txt and check with shell script
Greetings people, I’m here with a python code that brings me the milliseconds of the E-tax Note Sending ping from the E-tax portal in the NFC-e status portal as below : #!/usr/bin/env python # -*-…
-
0
votes2
answers239
viewsSelect only a part of the Dataframe title
Imagine the following situation, I have a Dataframe with any name. Within this Dataframe I have columns with the following titles More(abc), Less(abc), Sub(abc), following the data of each column.…
-
0
votes2
answers308
viewsPython function together with html, how to reconcile?
I have a select: <select class="form-control"> <option value="0" selected>Selecione uma opção</option> <option value="1">1</option> <option…
-
0
votes1
answer116
viewsRepetition of values within a Dataframe
I’m conducting a data analysis on a dataset which displays temperature data (from January to December) over the years. By importing the dataset I found that it has some inaccurate temperature values…
pythonasked 4 years, 11 months ago Felipe Roque 57 -
0
votes1
answer815
viewsHow to handle a windows window in python?
Next, I have a very simple code that just opens an exe program import os caminho = os.startfile(r"C:\Program Files (x86)\Nox\bin\nox.exe") However, when running, the application window comes…
pythonasked 4 years, 11 months ago Gabriel Henrique 45 -
0
votes1
answer5223
viewsHow to manipulate CSV data in python?
I need to manipulate data CSV without using pandas or numpy. It has specific columns to manipulate, so how do I best go through the columns, do this data reading of each one and be able to work with…
-
0
votes1
answer732
viewsLoop to run python scripts
I have a loop process to run scripts in parallel, but the VPS that I will last does not allow to use parallelism, In that case I need to create a code like: scripts = [ 'siteodonto.py',…
-
0
votes1
answer1248
viewsCreating new environments (Nvironments) in Anaconda 3
First I apologize if my question is too basic or if it doesn’t make sense to you, I’m still starting my walk in the Python language. To the point, my question is: Why should we create new…
-
0
votes0
answers53
viewsPython Losing Class Reference
I need help with a class reference problem. My class is losing the reference in the middle of a While and I’m not getting to figure out why. Gives the following message: Erroinstance '' has been…
-
0
votes1
answer778
viewsSeparate values from a JSON in multiple fields
I’m doing a task in Python that requires me to search some data in a database. One of these values returns in the format of a JSON, the problem is that I need to make a "split" of these data since,…
-
0
votes2
answers967
viewsI want to close a python file and then open it again
Do not call the variables name. When the program tries to open the file after closed, it does not open. from time import strftime n = 2 cl = 2 abrir_arquivo =…
-
0
votes1
answer112
viewsData Crawling in Python
Good afternoon, you guys. I decided to start my studies with the Python Crawler technique. I built the following script using lib Selenium : # Importando selenium para realizar o crawling from…
-
0
votes0
answers41
viewsProblem with webscrapping (requests)
Precise scrape this site to search for doctors in a category. I send the requisition all right, pass the value (the type of doctor) and send via POST the requisition. However it does not return the…
-
0
votes2
answers2009
viewsPYTHON - FOR inside FOR
I’m performing a select on DB with the Python and treating this return. My doubt is in the use of a for within other’s for, use the script below: import mysql.connector mydb =…