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
answer14
viewstemplates extends from project to apps
I have a project created from startproject ... command where in the structure of it, I created a templates folder, in which, I wish to have templates htmls bases, ie extending them to the templates…
-
0
votes1
answer180
viewsRequests not being sent with payload in Python - Moodle
Good afternoon, I’m having a problem that’s already giving me a headache. The blessed request payload is not being sent to the webservice, only the url. My code is like this: class Curso: '''Resgata…
-
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
votes1
answer978
views -
0
votes1
answer638
viewsHow to change only one color in Pillow (Python)
On my website, I managed to get ?size=200 in an image link, resize the image to width 200, maintaining aspect, I want to do the same, only with ?fill=ff00ff that would change all white color to…
-
0
votes1
answer1188
viewsHow to leave a single version of Python on Linux/Ubuntu?
I even understand the fact that there is Python2.7, which in itself is quite annoying because every time I lower the modules to the wrong place, but when I tried to upgrade the version 3.6 to 3.7…
-
0
votes1
answer69
viewsPython reading database postgres
In python I use callproc to perform a function done in the postgres database. It works well if you access the bank by the user with full permission. But error occurs when accessing with private user…
-
0
votes1
answer1773
viewsHow to pass data from one input to another with HTML and Python?
Guys, I have a problem in my application and I can’t find the solution on the internet. I’m making a web application in which I need to get some user information and to improve the experience, I’m…
-
0
votes3
answers1537
viewsCalculate the age group of 10 people within a repeat loop?
Below is the code I am using, this presenting the following error: SyntaxError: invalid syntax maycon@maycon-H14SU08:~/Documentos/Algoritimos$ python3 prova_lista.py File "prova_lista.py", line 23…
-
0
votes1
answer397
viewsHow to run python code by anaconda prompt with php?
Staff follows description for understanding: 1 - I have the code of a classifier written in python 2 - I want to run it from php (shell_exec() for example) but not using the windows prompt but…
-
0
votes1
answer343
views'Botfalante' error Object is not callable
I am creating a virtual wizard in Python, but with some difficulties. Follow the code: #-*- coding: utf-8 -*- from chatterbot.trainers import ListTrainer from chatterbot import ChatBot import…
-
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
votes1
answer14224
viewsTypeerror: list indices must be integers or Slices, not str
Hello, everyone. When I run this code I get the following feedback: Typeerror: list indices must be integers or Slices, not str How can I fix this? import pagarme import psycopg2…
-
0
votes0
answers118
viewsProblem collecting links from a website
Dear friends, good morning! I am writing a program in Python to collect the links of a website. The part of the code that collects the links is: links = driver.find_elements_by_xpath('//*[@href]')…
-
0
votes1
answer897
viewsCreate tuples with random values
Is it possible to create a tuple with random size and values? If so, how? ex: Run -->(0, 4 , 5) Run --> (2, 1, 7, 9) Run --> (7)... If it was a list I’d use the code: from random import…
-
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
votes1
answer1982
viewsdefine a polynomial of any degree in Python
I work with numerical calculus, my goal is to make use of a "least Squares". I’m defining a function in Python as follows: def F(P,x): return P[0] + P[1]*x + P[2]*x**2 + P[3]*x**3 Then I will define…
-
0
votes1
answer632
viewsPandas: Convert Dataframes to Image
Given a Dataframe as the following: df = pd.DataFrame({'id_emp' : [13524791000109, 12053850000137, 4707821000113, 4707821000114, 1], 'name_emp': ['Cristiano', 'Gaúcho', 'Fenômeno','Angelin',…
-
0
votes1
answer311
viewsPeak value of a histogram
My code reads an image and transforms the RGB color model to HSV, and then I make a frequency histogram of each channel (H, S and V), with H varying from 0-179 and the rest from 0-255. With…
-
0
votes0
answers17
viewsPython (superscription)
Is there a way I can overwrite the content of a print without manually writing it, after a time.Sleep()? Ex.: print('Me ajudem!') #Texto "inicial" time.sleep(3600) #Após um minuto, o texto inicial…
-
0
votes1
answer1123
viewsHow to get only the records not duplicated with pandas
How would you get only the un-duplicated lines of a dataframe? Without them being single records, so df.unique() would not fit here. Only the ones that exist 1 same. I tried that way, but I don’t…
-
0
votes1
answer352
viewsHow to make server threads in Python?
Hello I’m a beginner in Python and I’m creating a simple server but I can’t create independent threads. When the client connects to the server it calls the worker function that waits for a client…
-
0
votes1
answer43
viewsRepeat result when reading local xml
I need to capture two attributes of an xml (date and type), even managed to make the script returns the values, but is repeating in the result of print and I can’t understand why. XML file: <?xml…
-
0
votes1
answer1593
viewsConvert column to string where have pandas null values
How do I convert a column to string every time I try to do `df['COL1'] = ['COL1'].astype(str)` where there are nulls, pandas convert to string "NAN", have some way around this problem?…
-
0
votes1
answer26
viewsLarger Image than the Frame
I need the image of a graphic, just stay inside the green frame, I can see the whole picture. Can anyone help me complete this goal ? Below is the function attached to the Seletionsort button, which…
-
0
votes1
answer545
viewsPyautogui for virtual keyboard
I am working on a project using Python 3.7 and the Pyautogui library. I have a website that needs to login using the mouse to type on a virtual keyboard. The problem is that the keyboard changes…
-
0
votes3
answers872
viewsHow to validate if a value is a tuple having a string and an integer?
I want to write a function that takes an argument (any type) and returns true if the argument is a tuple (double elements, double elements of 2), where the first is a name (str) and the second is an…
-
0
votes1
answer22
viewsProblem: No name 'departments' in module 'funcionario.apps'
I cannot pass this phase because when compiling it presents the error : No name 'departments' in module 'funcio.apps' from django.db import models from django.contrib.auth.models import User from…
-
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
answers88
viewsLibrary import inside or outside functions
I was wondering if it is correct to import libraries within functions? Or it is better to import the library in the file that the function is called, but the function will only work if the library…
pythonasked 5 years, 5 months ago Eudson Durães 98 -
0
votes1
answer34
viewsWhy does smtplib instance not return a dictionary?
I’m starting my studies in Python and I have a question. While reading the ebook Automate the Boring Stuff I come across an instance that returns a certain object. import smtplib smtpObj =…
pythonasked 5 years, 5 months ago Guilherme Hirsch 3 -
0
votes1
answer786
viewsHow to add external training in chatterbot
I created a very simple bot to learn how to use chatterbot. This library already comes with a training, but I wanted to put an extra training with the import of a corpus in Portuguese that I found…
-
0
votes0
answers53
viewsCan anyone help write this program in python that involves tuples?
I am writing the python "check" function, which takes an argument of any type and returns True if that argument is a Tuplo whose elements are pairs (2-element doubles), where the first element is a…
-
0
votes1
answer2254
viewsHow to click on links with Selenium Python
I have this tag <a href="!!!!!!">carro</a> I use the following code do = driver.find_element_by_link_text('carro') do.click() I cannot access, returns the following error:…
-
0
votes1
answer148
viewsI would like to know how to find this Aria-label attribute in python xpath
I’m looking for the Aria-label attribute using Selenium with the code below, but I can’t find it. xpath =…
-
0
votes1
answer2337
viewsHow to access an iframe using Selenium Python
Does anyone know how I can access an iframe from a web page without the iframe ID and NAME ? I know there’s a command calledswitch_to_frame.
-
0
votes2
answers77
viewsELIF using not in, inside a FOR
I would like to know if there is any way to refine the ELIF within a FOR, so that it does not enter into it whenever the date does not exist, but if that date specifies it does not exist. Follow the…
-
0
votes2
answers290
viewsValidation of input data using functions, Try and except
try: number = int(input("Por favor, digite o seu número aqui e veja o que acontece: ")) except (ValueError, TypeError): print ("Por favor, insira somente números inteiros positivos") try:…
-
0
votes2
answers259
viewsProblem in Pickle library in Python
So, trying to apply the following code, but the compiler ta returning me following problem, I can not think of anything that is not some installation problem, but I got this problem in two different…
-
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
answer318
viewscreate an MDI screen with Python and Pyqt5
I’m making a system with Python and Pyqt5. I already created the menus and now I’m applying the necessary functions of each item. I want to work with MDI screens and I’m having difficulties with it.…
-
0
votes1
answer1038
viewsRelationship Django Models
I have a model called Item and made a call Compra. I was able to relate several items with each purchase, but I don’t know how to relate the quantity of each item in each purchase. class…
-
0
votes0
answers111
viewsError in python API call - Jsondecodeerror
I’m making this call in a Mailchimp API, but it’s returning an error in json that I don’t know how to solve, can help me?? My code: import requests import psycopg2 key = 'KEY' url =…
-
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
answer401
viewsPython mining (prediction using csv)
I am now starting programming in Python language and I am studying data mining with artificial neural network. What should I do to make predictions from a . csv file? Then how to save the results in…
-
0
votes1
answer145
viewsCheck List elements within other Python lists
Good, I have two lists lista1 = [0,1,2,3] lista2 = [0,1,2,3,4,5] How do I confirm that all elements of list 1 are within Lista2 ? For example : lista1 = [0,1,2] lista2 = [1,2,3,4] lista3 = [0,1,2,3]…
-
0
votes0
answers193
viewsHow do I move a file to a folder that the code itself created? (python)
Good afternoon, you guys. I wrote a program so that after the user has entered a name, a folder with this name will be created and then a file (from another folder) will be moved to it. The folder…
pythonasked 6 years ago Jordan Garcia 35 -
0
votes1
answer31
viewsProblems using iloc pandas
I want to create a new DataFrame with the following condition: marvel.loc[ marvel['Orientation'] != 'NaN' ] I mean, I want every line that has the column 'Orientation'== 'NaN' are deleted, but there…
-
0
votes1
answer1193
viewsHow to send images via socket in Python?
So is the server: import socket from PIL import Image port = 8000 host = '127.0.0.1' s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((host, port)) s.listen(5) while True: conn, addr =…