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
answer662
views'Nonetype' Object has no attribute 'groups'
I’m using a function in mine Templatetagsdjango that basically checks if the user is in the group that has the permission for the given button. The return 'True or False' works well, IE, it shows…
-
0
votes1
answer59
viewsDoubt about the replace() method
The replace() method is a method of the str class, correct? Follows a code that 'rotates' perfectly where the object is an integer (or at least in my interpretation). Or in the case of interpolation…
-
0
votes0
answers369
viewsPyodbc Error: ('HY000', 'The driver Did not Supply an error!')
I’m having a little trouble using the pyodbc to connect to an MS Access. Until a few days ago, everything was operating normally, but after updating my Anaconda, a persistent error occurred in the…
-
0
votes1
answer232
viewsPython thread
To be very quick I’m trying to create 10 threads so that 10 attempts at a time are made, that is, from 10 to 10 so that the process is streamlined saving time and processing(maybe), my initial code…
-
0
votes1
answer36
viewsShow Postgresql data on web page
I’m new to the subject and ended up stuck in the web. I would like a help to display/search Postgresql database information and show on a web page. As I am learning Python, I would like help in this…
-
0
votes1
answer794
viewsReplace certain values by media in a pandas Dataframe
Hello, I have a Dataframe as image below. I would like to replace the Nan values of the QTDVENDADIARIA column with the media of the two previous records (40+27/2), in the same way the price column…
-
0
votes1
answer140
viewsHow to limit the number of lines in a Listbox in Tkinter
I’m studying about Tkinter and I came across a problem when I wanted to limit the amount of results that appeared on a Listbox. I looked it up online, but I couldn’t find anything on it. I am…
-
0
votes1
answer326
viewsPass view parameters to Django form creator
I have the following application where it is supposed to be possible to edit the details of a selected room. In the file that handles the view I query the database of the selected room for editing…
-
0
votes0
answers34
viewsPython NLTK does not correctly classify my text even though show_most_informative_features looks okay
Talk guys, I’m learning to mess with Python’s NLTK for a course, using the teacher’s example base, everything works fine, but when using a base of its own, something strange is happening and as I…
-
0
votes1
answer563
viewsReplace blank data in a list (Python)
I have a list that will receive input data and make a for loop to go through the list to find empty strings to replace them. I’ve tried to use lista.remove() and lista.append(), but the value that…
-
0
votes0
answers39
viewsExporting data to Firebase
I’m trying to export a Python database to Firebase. My database is a JSON in the following format: '{ "0":{ "country":"Italy", "description":"Aromas include tropical fruit, broom, brimstone and…
-
0
votes0
answers125
viewsVCRUNTIME140.dll was not found running cx_freeze executable
A few days ago I developed a Python application and managed an executable using the package cx_freeze with the following code: from cx_Freeze import setup, Executable setup( name = "Minha…
-
0
votes1
answer217
viewsReceiving numerous data with Python socket
I’m having a problem with my script, I have a server.py and a client py. and my problem is to receive and send large amounts of bytes. I want to transfer large amounts of bytes of files to the…
-
0
votes1
answer164
viewsUPDATE ON DJANGO
I’m a beginner in Django and I’m trying to crud, create, read and delete are working, but the update is not working. Please help me out. This is the page with the data listing: <table…
-
0
votes2
answers78
viewsHelp to parse data and turn it into a dictionary
Guys I have the following problem and I would like help to turn a log file into a key and value dictionary for later use more I’m stuck on the code. I have the following data and would like help to…
-
0
votes1
answer49
viewsProblem reading file and turns it into a key and value dictionary
I have the following problem when going through a text file and I am not able to solve, I believe it is simple the solution, more need help to get to it. I have the following code: import re dic =…
-
0
votes0
answers49
viewsHow to make the program automatically recognize input as int or str?
My question is simple: I want to create a code that the user type anything and the program returns some information about what he typed. (type, characters, etc.). It is a very simple program, but…
pythonasked 4 years, 9 months ago João Victor Lima 1 -
0
votes1
answer87
viewsIs it possible, somehow in python, to create attributes in a class that is common to all objects?
Is it possible, somehow in python, to create attributes in a class that is common to all objects? And somehow if it is changed during the execution of the program change to all objects already…
-
0
votes2
answers658
viewsCheck if the values of a certain Dataframe column exist in a certain list using np.Where
Hello! I’ve been trying to check if a certain value present in a certain dataframe column is present in a list, using np.Where. In other words, it would look like this: df = { 'Pais': ['Brazil',…
-
0
votes2
answers954
viewsRead a txt avoiding problems with python accents
I’m trying to read a txt file but using the function below to display colors in the terminal and whenever the file has accents it returns me all messed up. COLORS = {\ "black":"\u001b[30;1m",…
-
0
votes1
answer58
viewsHow to make the number of executions of an algorithm a function of processing capacity and not of time?
I wrote a little program to send a message on my father’s Whatsapp to remind him to take his meds. Below I present the code that can be replicated by anyone with a mobile number and a record in the…
-
0
votes2
answers737
viewsRestarting a Python script with Input
I have the following program below in Python with 2 functions, one to convert real in dollars according to the quotation, and one to convert dollars to real also according to the quotation, plus a…
-
0
votes0
answers51
viewsPython ctypes ERROR: Exception: access Violation writing 0x00DEF6CC
I’m trying to import a dll C/C++ with the lib ctypes and use a function that it has internally, when passing the parameters to this function I always come across the error: ERROR: exception: access…
-
0
votes1
answer164
viewsNamed async Python class
I would like to call a class that does a post for an Endpoint but that this call was not blocking, because it is inside an event that sometimes triggers 5 cohorts in a row and I can’t wait for the…
-
0
votes1
answer256
viewsProblem to convert . py to executable with cx_freeze
I tried several times and it does not work in windows 7 and in other versions the interface opens does not connect to the DATABASE all dlls have already been imported '''from cx_Freeze import setup,…
-
0
votes1
answer40
viewsNested structure giving error
I’m trying to create a script that reads if the person is older or younger. I would like if for example only 1 person is bigger, it writes '1 person' and not '1 people', but my code is giving some…
-
0
votes1
answer65
viewsDuplicated, how to pass more than one parameter?
I have two CSV, I want to compare more than one field using duplicated. Is there a way, or can I just pass one parameter at a time? I followed the direction of Clayton Tosatti and I got here, but…
-
0
votes0
answers400
viewsWrite in Excel using Python
I am using python for automation, where I need to set a series of information in the spreadsheet. I understand I need 2 for, one to traverse a row and the other the column, I need to define a limit…
pythonasked 4 years, 8 months ago Marcos Reis 11 -
0
votes1
answer93
viewsBasic closures
Sirs, I’ve been studying Python for about four months and now I’m entering the most complex concepts of language. I’m having a little trouble assimilating decoradores but I understood that first I…
-
0
votes1
answer38
viewsIs it possible to use K-Means (or another Clusterization method) with point limits?
I am developing a cluster code with k-Means and I have the following question: It is possible to determine the point limits per cluster with k-Means or another algorithm? Explaining the case better,…
-
0
votes2
answers108
viewsDoubt Python with Firebird database query
Hello I have a problem with the Firebird database query. I make the connection with the bank and step this query, but the problem is in return, it returns the name of the normal product only that…
-
0
votes1
answer364
viewsAdd midline with Seaborn - python
As I include a vertical line referring to the average of each of the classes in the histograms, using Abor? import numpy as np import pandas as pd import seaborn as sns from sklearn import datasets…
-
0
votes2
answers142
viewsProblems for player play order in Tic-tac-toe
I have trouble with the job players(), because I can’t increment the variable n, the function is only returning "X". I know it sounds pretty simple, but I can’t identify the problem. Can anyone help…
-
0
votes1
answer101
viewsUpdate all Fields of a model, except the key Primary
I am starting the studies in DRF and during a test I came across the following situation: it would be possible to change the fields of a class with the exception of primary key? My first attempt was…
-
0
votes1
answer693
viewsFilter and Join with Django ORM
I have 2 tables, one called Formsitems and another called Formstypes. Formsitems has an FK for Formstypes where the type of field that item is indicated. Using SQL I managed to make a Join between…
-
0
votes1
answer337
viewsJavascript is not working on Django
I’ve tried every way, but I can’t make the JS work. login js.: $('.message a').click(function(){ $('form').animate({height: "toggle", opacity: "toggle"}, "slow"); }); login.html; {% load static %}…
-
0
votes1
answer208
viewsHow to use a global variable in a python function?
I’m trying to make a system of lootbox in python, but I can’t use an outside variable within the function from main import player from random import randint p1 = player class item: def lootbox(a,c):…
-
0
votes1
answer102
viewsCheck WORD style in DOCX via Python
I am trying to verify a document (.DOCX) And pick up the text that is with a certain style. Turns out the code I came up with in my attempts can only get the whole paragraph. I’d like to take part…
-
0
votes1
answer67
viewsHow to display different scope subplots in the same figure?
1 - Summary of the problem I’m trying to implement the Binary Backpack Problem, using Python and a simple genetic algorithm. Follows the repository on Github. I wrote functions for plotting the…
-
0
votes3
answers655
viewsHow to repeat these commands in Python
I would like to know how I make a command for the program to keep repeating this code a certain amount of times. I want him to repeat this code in one minute:…
-
0
votes2
answers860
viewsCheck if number is equal to the sum of squares of 4 consecutive prime numbers
I need to do a program where I type a number and the program checks if it is the sum of the square of 4 consecutive primes. Example: 2020 has to give 17 2 + 19 2 + 23 2 + 29 2 My code for now is…
-
0
votes1
answer66
viewsCustom menu
I’m creating a simple script with a def I printed out a custom menu. The first parameter is the header, followed by the number of items accessible by the menu and finally a third parameter that is…
-
0
votes1
answer112
viewsPyhton "No module named" error with local imports
I created a simple App using Flask, but I have a problem when importing the "Resources" that I created into another file. This is the main file: from flask_restful import Api from flask import Flask…
-
0
votes1
answer111
viewsDelete without giving error
I have two models, one has the foreign key in the other. I wanted to implement a delete, that would prevent her from deleting that key when she was already safe in a relationship. In the view.py I…
-
0
votes1
answer164
viewsTransform column with Nan and string to integer
I have a dataframe with the following column: Years 0 1990 1 1990 2 1990 3 1991 5 NaN 4 1994 6 NaN ... ... Name: Years, Length: 9742, dtype: object I have already performed part of the cleaning of…
-
0
votes1
answer30
viewsFlask does not expect function return to show view
I have a function that returns values to be shown in the view. In tests on localhost works perfectly, the server waits for the return of this function and only then presents the data on the screen.…
-
0
votes0
answers58
viewsNo response when trying to run Python proxies
I’m trying to write a code to make my own Scrapping on the Web and I’m trying to implement the proxy rotation, but I’m not getting any results. I’ve checked many websites and forums about this…
pythonasked 4 years, 8 months ago user181857 -
0
votes1
answer100
viewsAccess data and change csv or txt with python
I have this script that does data negotiations, I took some examples from the internet but could not access the data, before recording in csv I need to modify some fields, for example, the field…
-
0
votes1
answer175
viewsPython only reads the last word of my Wordlist
I’m starting in python and I picked up an educational script from bruteforce. However, when the script reads the Wordlist passwords and users, it only takes the last record and ignores all the…
pythonasked 4 years, 8 months ago Daniel de Aguiar 11 -
0
votes1
answer149
viewsHow to Decrease Complexity of a Function with Two Loops in Python
This function returns the number of pairs in which A[i] > A[j] for 1 < i < j < n def calc(A): cont = i = j = 0 while i < len(A): j = i + 1 while j < len(A): if A[i] > A[j]: cont…
pythonasked 4 years, 8 months ago Pirategull 659