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
answer45
viewsvector operation
I have two variables M1 and m2 that change each data set that imports and a vector (measured) with the values, need to see if the values of the vector are greater than M1 or smaller than the M2 and…
-
0
votes1
answer368
viewsFormatting of float types
I did a little research before I asked, can you tell me why it doesn’t show 2,500 on the way out, but 2.5 salario=float(input("Digite seu salario")) print(salario)
-
0
votes1
answer930
viewsFor Python, what is the difference between Pip x Conda x anaconda
I’m learning python and saw that always appears tutorials for the tools: Pip Conda anaconda And I wondered what the practical difference was between them?…
-
0
votes1
answer757
viewsHow to use JSON in Python?
I am using the following code to collect the API from the Urbandictionary site import requests import json page = requests.get("http://api.urbandictionary.com/v0/define?term=hello")…
-
0
votes1
answer3303
viewsConvert monetary value (string) to Python/Pandas float
I’m reading a csv file where one of the columns has monetary values like '10,000.00', the pandas is interpreting as string. I wonder if I will have to convert this into race (iterating on all the…
-
0
votes1
answer50
viewsIteration with variable of type 'TIME'
I am doing a project in which I need to perform a loop that increases minute by minute of a variable from two times informed. I thought of logic as follows: vHoraInicial = '13:30' vHoraFinal =…
-
0
votes1
answer544
viewsKivy does not run error in text editor
Hello I just installed kivy in windows following the step-by-step kivy.org site. When I try to run a test script, I get a message on the pycharm console that the execution has been aborted: "Unable…
-
0
votes1
answer410
viewsPython: loop screenshot saving over
Why the code below saves the file one over the other? I wish that every screenshot generates a separate file within the specified folder. import datetime import pyautogui import time #armazena o…
pythonasked 6 years, 6 months ago Wilson Junior 182 -
0
votes2
answers91
viewsHow to create the <!DOCTYPE html> tag in Beautiful Soup (bs4)
I wish to create the tag in Beautiful Soup (bs4), and developed the following: from bs4 import Doctype tag = Doctype('html') I did the above excerpt. But it does not create the tag . How to proceed?…
-
0
votes1
answer507
viewsDjango + AJAX - POST 404 (Not Found)
I am trying to implement a Likes system in a Django + AJAX application but when trying to do the operation in question I am getting the following error in the browser console: POST…
-
0
votes1
answer937
viewsCatch element using python json
I’m using the following code to try to get what’s written inside definition, located in list import requests import json word = "salut" page =…
-
0
votes1
answer152
viewsHow can I create a dynamic database in Pyhton
Could someone help me on how to create a dynamic database, where I can add and remove items? In Python, if possible with Sqlite
-
0
votes1
answer839
viewsHow to perform operations between arrays in python
Hi, I’m learning python, I saw the basics and I’m in a problem where I need to do operations between arrays. I have, for example, two arrays of equal dimension D. For each index I in the array, I…
-
0
votes1
answer45
viewsProblems configuring views using Jango
I’m studying Jango and I’m having problems in the following part {'posts': posts} I’m using as ide pycharm and it shows error but for me the syntax of the code is correct. from django.shortcuts…
-
0
votes1
answer152
viewsPython - Type function in tuples
Hello, I’m trying to make a program in Python, which gets a positive integer number. That program shall verify that it is whole (with the type function) and if it is positive. Should return a…
-
0
votes2
answers977
viewsPython - Find a tuple odd
I’m new in this area and recently, for a college job I couldn’t turn this line of code into tuple. function code: def encontra_impares(lista): lis = [] if len(lista) > 0: numero = lista.pop(0) if…
-
0
votes1
answer81
viewsPicking up data in pairs in sequential lines
I’m reading a spreadsheet csv with pandas across pd.read_csv(). The spreadsheet contains vehicle location data every moment. For example: Place 1: Latitude a, Longitude a Place 2: Latitude b,…
-
0
votes0
answers436
viewsConvert HTML to PDF and insert Image with Django
The image does not appear in PDF, I use xhtml2pdf. reports/sol_access.html <img src="{% static 'img/small_logo.png' %}" alt="Blue Tech" style="max-width:200px; margin-top:10px"> view py. ` def…
-
0
votes1
answer432
viewsHow to change an attribute in a list of objects and write that list in a file
I have a list of objectsconList I want to change an attribute of an object and then write that list in a file, where each line of the file is an attribute of each object in the list. How do I do it…
-
0
votes3
answers2778
viewsSeparate data from a txt file
I have a relatively large file of data, which I removed from a time-stamping machine, but it comes in the following way: 00003000527005792012635570932000219305130720170713…
-
0
votes2
answers121
viewsGenerate querysets from dynamically generated rules
I’d like to make a sort of filter using Django. Imagine the following case: Model: user (Name, sex, age, dia_nasciemnto, mes_nascimento, etc) Rule: Catch all users with Sex=M and Age>20 The…
-
0
votes0
answers38
viewsHow can I call a.py program on a server within another local.py program?
I’ve been interacting with a server within a program I’m doing using the os.system() function as if I were using the console itself. os.system("ssh [email protected] 'comando a ser realizado'") For…
-
0
votes2
answers602
viewsObject orientation in python
I’m a beginner in Python, I took some courses and I’m trying to learn Tkinter, I found a playlist on youtube with a guy who made a BTC trading app with Tkinter and he created a class to open more…
-
0
votes1
answer106
viewsApplication for login on another site (Facebook), error "Invalidsubmiterror"
My code is this: import robobrowser import re url = 'https://m.facebook.com' loggedin_title = 'Facebook' # isto vai servir para confirmarmos que estamos loggedin, vendo o titulo da pagina para onde…
-
0
votes1
answer67
viewsError trying to encrypt with BCRYPT in Python
Code: import bcrypt hashed = bcrypt.hashpw('teste',bcrypt.gensalt()) error: Typeerror: Unicode-Objects must be encoded before hashing Running the program shows this error, how can I fix?…
-
0
votes1
answer43
viewsHow to change form fields depending on the user
I’m using Flask Admin and Flask Security to log in. I can easily define depending on a user’s role whether or not they can create an object, but I would also like to be able to add or remove fields…
-
0
votes1
answer160
viewsWhy if I rename the folder the files inside it change?
I’m using Lubuntu 17 and had a folder called images with some files dai was trying to rename these files with this programming in python: import os import re def repl(match): dic = {"4": "0", "5":…
-
0
votes1
answer143
viewsAdd footer with xhtml2pdf on specific pages with Django
I have a standard footer that is displayed on some pages when generating the PDF with the xhtml2pdf using Django which should be positioned at the bottom of the page. But in some I don’t want to…
-
0
votes1
answer148
viewshow to handle a json that contains several results using python
Hello, I’m making a python script that takes the name of a movie and returns some data to the user(title, year etc). I am using the omdbapi, but my doubt is not about it but about how to handle the…
-
0
votes0
answers67
viewsProblem with Poloniex API
I’m having problems with the Poloniex API, when I run the code polo = poloniex.Poloniex('key', 'secret') polo.sell('BTC_MoedaX', 0.003, 3) polo.buy('BTC_MoedaX', 0.003, 3) Returns the error:…
-
0
votes3
answers1806
viewsAdd the first "n" elements of a Python geometric progression
A program to add up the first "n" elements of a progression geometric, given the first element "A0" and the ratio "r" between the elements. For example, for n = 7, A0 = 1, r = 3: 1 + 3 + 9 + 27 + 81…
pythonasked 6 years, 6 months ago Réulison Silva 96 -
0
votes2
answers96
viewsWhat’s wrong with this print line = ('Hello,' + full_name.title() + '!')?
I’m new to programming and I’m following Eric Matthes' book exercises. In the text editor, I typed print = ('Hello,' + full_name.title() + '!') and an error message appeared.…
-
0
votes2
answers65
viewsWhy can’t variables from the same instance be read in different processes? (Python)
I have two processes going on and I have a class containing a method that modifies a value, as you can see in the code below. The Eventoboton function represents a click to modify a value. But the…
-
0
votes2
answers997
viewsfilter list in Django admin Foreign key field
I have two questions, both related to the form generated automatically by the Django admin. If I create an administrative screen I know how to solve these problems, but working directly with the…
-
0
votes2
answers2303
viewsRandom Choice in python
I’m a beginner and I’m creating a program to make tables, but I didn’t want the program to follow a growing order like "1x1, 1x2" and so on. So I used a "Random.Choice" function to show the tables…
-
0
votes3
answers9117
viewsconvert a string list into a list of integer numbers
x = ['443' , '552' , '342' , '368' , '9867' , '335' , '9412' , '7436' , '1692' , '85' , '990' , '332' , '8816' , '4567' , '279' , '119' , '2290' , '234' , '9863' , '345' , '230' , '5574' , '230' ,…
-
0
votes1
answer8329
viewsFormatting two decimal places using list (Python)
I have a question about the formatting of decimal digits using two houses, for example "2.00", I did this exercise but I have a little problem that I can not solve as I do not know if there is a way…
-
0
votes1
answer793
viewsNoreversematch error in Django
Hello! Studying on Django and developing in this framework, I came across the following error: Noreversematch at / Reverse for 'displayURL' with Arguments '('',)' not found. 1 Pattern(s) tried:…
python python-3.x web-application django django-templatesasked 6 years, 10 months ago Thiago Benine 95 -
0
votes1
answer974
viewsWrite a string list to a file
I have a list and I wanted to write in another file ["AMANDA,"JULIANA","VANESSA","PATRICIA"] In a document using Python, I managed however the file gets all together like this:…
-
0
votes3
answers3331
viewsReturn the amount of elements repeated in a list
Could you help me with a question? How do I return the amount of elements that repeat in a list in python? For example: A list=[4,2,1,6,1,4,4] must return the value 2, because there are two elements…
-
0
votes2
answers1305
viewsHow to turn a list into a set in Python?
I’m trying to intersect the player list with the computer list, but I’m getting an error that says "line 13, in print(set(player).intersection(computer)) Typeerror: 'int' Object is not iterable".…
-
0
votes0
answers27
viewsPython: Rescue mysql html text
I am using Bottle.py for study and testing... I have a problem in retrieving a database information. The table is like this: create table if not exists postagens ( idPostagem INTEGER NOT NULL…
-
0
votes2
answers302
viewsUsing variable in chdir function (module OS)
It would be possible to use the informed data in a variable in some other function other than the chdir() module AS python? I realized that it is not possible to use variables in the exchange of…
-
0
votes1
answer483
viewsMatrices in python
I have to make a program that receives an array of letters a number of words to be searched in the matrix and the words themselves, for example: u l i o a e a p b e a r y l s j i t u a e e h u b e u…
-
0
votes1
answer191
viewsprint("...") is running several times
I made a program to check if the reported CPF is valid, but a bug is happening: When I type a valid CPF immediately, the "Cpf..." message is printed once. When I type a wrong number and then enter…
-
0
votes2
answers241
viewsAutomation of tasks in linux
Well, I already know python and I know she’s very good at working with scripts and task automation but my question is, i can work comfortably with administration and automation of linux and database…
-
0
votes1
answer98
viewsI cannot save the information to the Database (PYTHON MYSQL)
I am trying to insert this query, but it n registers in the Mysql table, however I realize that it is accessing right, because it always uses a position of 'Cod' which is primaryKey *when using the…
-
0
votes2
answers1526
viewsIgnore any white space in the middle of a string
I am trying to create a regex that is able to find a string in a text even if there is some white space in the middle of the words. For example, I look in the text for the following excerpts…
-
0
votes2
answers1943
viewsHow to link to download html file?
I’m using the tag: <a href:"{{ arquivo.caminho }}" download>link</a> with the download attribute to download a link of files from my local network (tiff images), however, the downloaded…
-
0
votes4
answers725
viewsFunction that returns the element with more characters from a list
I arrived at the following function: def func6a(lista): maior = 0 for el in lista: if type(el) == list: maior = func6a(el) else: if len(el) > maior: maior = el return maior But unfortunately,:…
pythonasked 6 years, 6 months ago GratefullyDead 373