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
answer184
viewsCreation of empty csv
hello on the python code below, I want to create a csv with the sum of inhabitants in each state but it creates an empty csv file please, someone has idea of the problem? the original csv file in…
-
1
votes0
answers153
viewsPandas Dataframe to_html or iterate over the data in the template?
Actually I wanted to iterate on the data in the template? But how do I play my pivot’s dice in context and treat them in the template? df = pd.DataFrame(data) pv = df.pivot(index='cands',…
-
1
votes1
answer84
viewsCan I extend the admin form to my page?
I have a form created and displayed with the admin the way I want...but it is a site to fill out user registration, so the user does not have access to admin, I want the admin form to be used…
-
1
votes2
answers48
viewsPass value from one page to another’s input
i have an html page where the user type in the email and I perform the check. If that email is not in the database, it is a new user and therefore redirect to the registration page. On the…
-
1
votes1
answer304
viewsDictionary as input argument is being modified within the function
In the code below the dictionary used as input argument is also being modified by the function. I need to perform a deepcopy() at all times? def muda(a): a['valor'] = 50 return a dic1 = {'valor':…
-
1
votes0
answers192
viewsConnection problems with ldap using python ldap
I’m new to python, and I’m trying to make a connection to LDAP to verify the existence of an Active Directory user, however, when trying to connect to ldap using the following code snippet: l =…
-
1
votes1
answer44
viewsCount number of occurrences in a log file
I am trying to count the number of occurrences of multiple text patterns in a log file. My code is counting all lines of the file for all text patterns. Where am I going wrong? The log file looks…
-
1
votes0
answers34
viewsI need a program that figures out the number of occurrences of all the letters in a sentence
I need a program that discovers the amount of occurrences of all letters of a sentence, and that places the letter and amount occurrences of the same in a dictionary, key:value, letter…
-
1
votes1
answer806
viewsPython replaces only PHP or replaces PHP and apache?
The first language I learned was PHP, unfortunately. PHP runs together with apache, but I wanted to use python instead, but the tutorials I found about python for the web make it look like it…
-
1
votes2
answers247
viewsPython module usage in Django
I’m starting with Django and Python now and I have a question that may sound silly: I can use python modules and functions - and others installed - usually in a Django application?
-
1
votes1
answer108
viewsMachine Learning with a server language and another desktop language
I could use Python, for the machine Learning and C++ for a desktop program? The machine Learning is done on the server, correct?
-
1
votes0
answers778
viewsHow to extract data from Facebook with Pyhon?
I’m trying to better understand the behavior of people who liked my page; who they are and what they like. Is it possible to get this personal data from users (name, city, age, likes) with python on…
-
1
votes2
answers4032
viewsRemove specific Python characters
My doubt is the following, in this excerpt of code I am removing a character that specifies with the replace(): lista = [["de carlos,"],["des.dd carlossd,"],["Peixe, texto!"]] lista_separados =…
-
1
votes1
answer252
viewsDoubt about Python classes and methods
I have a question, I can’t do an exercise in classes and methods. 2 - Create the class "Date" with the attributes: day, month, and year. And create the methods "setarData(receives day, month and…
-
1
votes1
answer192
viewsError while running python script
I made this program in python : //////////color.py #!/usr/bin/env python # -*- coding: utf-8 -*- class Color(object): string = { "RED": "\x1b[31m", "GREEN": "\x1b[32m", "BLUE": "\x1b[34m", "YELLOW":…
-
1
votes1
answer3096
viewsHow to extract specific data from a Python text file?
I have a **text file of 49633 lines** (txt file) with the following format: -e Tue Mar 28 20:17:01 -03 2017 total used free shared buffers cached Mem: 239956 126484 113472 4904 10292 52280 -/+…
-
1
votes1
answer435
viewsQuicksort in ascending order in Python
I need to sort the number of times words repeat in the txt file, but every time I run the code it prints in descending order. Code below: from collections import Counter with…
-
1
votes2
answers997
viewsManipulating lists in Python
I have a list like this: Lista_A = [['de','do','da','ou'],['ae','ay','yhh','oo'],['ow','pa','la','for']] How do I leave her like this: Lista_A_new =…
-
1
votes1
answer140
viewsSave amount of occurrences of a txt file to another python txt file
This part of the code counts the number of times words repeat in the text: with open('/Users/DIGITAL/Desktop/Python/teste.txt') as f: ocorrencias = Counter(f.read().split()) This part is used to…
-
1
votes0
answers69
viewsPyqt5 - Mainwindow opens and then closes
main py. (dialog) if __name__ == '__main__': try: import sys from user_interface.ui.login import Ui_Dialog from PyQt5 import QtCore, QtGui, QtWidgets app = QtWidgets.QApplication(sys.argv)…
-
1
votes1
answer347
viewsReset variable
I am doing a search on the data anchor SQLITE3 inside my program and it returns values inside my variable, however when I make a condition to be executed for when the value is filled it returns…
-
1
votes1
answer108
viewsMagical python methods in javascript
Python objects have some magical methods like __init__, __str__, __eq__, __ne__, __gt__, __lt__, __ge__ and __le__. How to simulate these methods in javascript, for when I do console.log(obj) write…
-
1
votes1
answer122
viewsFill matrix with ZERO in null spaces, (python/Django)
The problem is in the parts marked on red, I’m having trouble assigning zeroes to her. According to model: The excerpt of the code I am generating this table: *Obs: The selection of this period may…
-
1
votes2
answers9721
viewsHow to find specific words in a python txt file?
I need to make a software that searches for words in the code and saves in a string the next line. I couldn’t find anything on how to do it anywhere, I just found one that counts the number of words…
-
1
votes2
answers670
viewsPython - Path indication of a file for reading
I’m trying to establish the way to read a table of excel for xlrd. But I get an answer saying that the C: cannot be used. How to correctly define the path of the files to be used? import xlrd…
pythonasked 7 years, 3 months ago Rodrigo Mendonca 21 -
1
votes1
answer348
viewsIs there a single way to use images in pygame?
I read in the documentation that the method exists image.load to read images, but it returns an object of the type Surface which is not always the most appropriate, so I wanted to know if there is a…
-
1
votes1
answer57
viewsNumpy delete method doing strange thing
i was testing the delete method of the array class of the numpy library and a strange thing happened: I had the element of Indice 0 deleted from the array, but the element of Indice 1 is deleted. I…
-
1
votes1
answer385
viewsError in Pascoa calendar algorithm
I was playing with programs that calculate dates, but I found a very precise python algorithm that returns me correctly the day that will fall and that already fell the holiday of Paris. The python…
-
1
votes1
answer957
viewsTake input from view
I have a form with the inputs: email, name and surname. The email will always have a defined format, so I want to take the elements and make it fill automatically in the other fields, example: User…
-
1
votes2
answers5641
viewsWhat is the use of the word "self" in Python?
excuse my ignorance on the subject because I’m starting now in the Python language, and for this very reason I wanted to know what works the reserved word "self". Thanks for your attention and…
-
1
votes1
answer275
viewsScrape list on website with beautifulsoup
I need to scrape in Python a list on a website. Only the first list My code is like this: import requests from bs4 import BeautifulSoup page =…
pythonasked 7 years, 3 months ago Reinaldo Chaves 333 -
1
votes2
answers12885
viewsHow to compile Python code in Sublime Text 3 running on the Linux operating system?
I’m editing the question to better explain what my question was. I am a linux user and am starting web projects in Python. Soon I made use of the text editor, Sublime text 3, but it has a problem to…
-
1
votes2
answers107
viewsHow to write user entries in python files?
I’m a beginner in python and I’m doing an exercise that asks me to create a simple database in a file. txt that allows the user to register and consult products and their values in real, without the…
pythonasked 7 years, 3 months ago Daniel Souza 11 -
1
votes1
answer519
viewsIDE to the Django?
Good evening guys, I’m having big problems with some ides, and I need your advice. I’m trying to program web projects in python, so I installed pycharm to work... It’s a great IDE at first, but it…
-
1
votes0
answers386
viewsMenu Generico using Python, Django and tree structure
I am creating a generic menu where a parent can have 1 child and so on (structure of a tree) and I have arisen a doubt of how to render the parents in a menu and when pass the mouse over the parent…
-
1
votes0
answers43
viewsExcel is crashing when using xlwings
I’m using python with excel through the xlwings package. The problem is that excel stops working whenever I try to import a function in the xlwings tab. I already restarted the pc, but the problem…
-
1
votes1
answer4647
viewsHow to manipulate strings with ". find"
I can use ". find" to make the program search for a word within a typed text and say whether it exists or not?(true or false) and what line of text is located, if not, what command do I use to do…
-
1
votes1
answer40
viewsDjango returning to Valueerror
I am creating a project to send emails, but I am doing some tests and I came across the following problem: The view send_mail.core.views.index didn’t Return an Httpresponse Object. It returned None…
-
1
votes1
answer200
viewsBar chart made in Python became "weird". Any suggestions how to improve it?
Friends, The following chart was generated: The code used was the following: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime,…
-
1
votes0
answers31
viewsPython Website/Forum
My questioning is not exactly about some code, but about where I can argue about. I’m starting in Python and sometimes I have some doubts or questions that do not fit to be asked in Stack Overflow,…
-
1
votes1
answer810
viewsHow to keep a key press in pyautogui
I would like to keep a key pressed for x seconds. I know that pressing the button is: pyautogui.press("key") But how can I keep her pressed?
-
1
votes2
answers501
viewsError in deploy Django/app in Heroku?
I need your help to try to find the error in my deploy, which I am trying to do in Heroku. Follow information from bash: (python3) user@Inspiron-5548:~/opt/anaconda3/envs/python3/Projetos/ecommerce$…
-
1
votes1
answer272
viewsHow to insert only elements that do not exist?
I have a script in python that searches elements of a database and saves in another, so when I run the script it is duplicating the data. sql = "INSERT INTO `alarm` (`data`, `seconds`, `culprit`,…
-
1
votes2
answers401
viewsHow to display text with multiple lines with format?
I’ve been trying for several lines in a row with one string along with the method .format, but I can’t. a=input("digite algo; ") print("""contem maiusculos:{} contem: {}n\contem números: {} contem…
-
1
votes2
answers2397
viewsHow to transform str into int?
I tried to turn the score into int as I did in Javascript but it didn’t work: placar = "0 x 0" print(int(placar)) I expected it to show 0 but it resulted in a mistake, as I do to turn the score into…
-
1
votes1
answer67
viewsPython - Mongo Engine Error: Tried to save Duplicate Keys (Duplicate Key Error)
Python I am trying to save more than one user in Json but it does not accept the introduction of more than one, always gives the: Tried to save Duplicate Unique Keys (Duplicate Key Error) here is…
-
1
votes0
answers143
viewsAvoid repeat names in json
I am looking for a form/function/method so that it is not possible to repeat the value saved in Json, for example: I am saving the json below and do not want to save the same name in json. [ [ {…
-
1
votes1
answer112
viewsDoubts regarding the PEP8
I read the PEP8 but did not understand very well when using 2 blank spaces. I must use 2 spaces to separate a section of imports from another section? What sections a Python file normally displays?…
-
1
votes1
answer1158
viewsFill JS Form - Web Scraping in Python - Selenium and Phantomps
Friends. I’m developing a code to access the Anbima, fill in the fields and download the generated txt. I have been looking for a solution to this problem for a few days. So far, I have found that…
-
1
votes1
answer112
viewsHow to transform a text into an identifier name?
I would like to be able to receive a string as a parameter and use as an identifier name, create a variable or function with that name (it is not used as a dictionary key). It is possible to do…