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
votes3
answers92
viewsAs I do in python for at the end of the code, it go to the start again
As I do in python to at the end of the code, it go to the start again and repeat once every 3600 seconds? My code: * fb = Facebook ( "meu-token" ) fb.testing = False try: start_time = time.time()…
-
-1
votes1
answer122
viewsProblem with excess Decimals!
Initially I was developing a python code that would help me better understand Nikola Tesla’s number theory(video). Explaining quickly, starting with 360, adding each separate value results in 9, for…
-
-1
votes1
answer90
viewsHow do you order the list, no repeat numbers?
I was given this list to sort without repeating numbers. What would be the best way to do? lst = [54,54,93,93,77,77,44,44] def bubbleSort(lst1): for x in range(len(lst1)-2,0,-3): for y in range(x):…
-
-1
votes1
answer57
viewsSyntaxerror: Invalid Syntax
I was creating a tool in Python, but when I went to run it gives this error. Excerpt from the code: while True: opcao = int(input("Digite a opcao desejada: ") if opcao == 1: arquivo =…
pythonasked 5 years, 6 months ago Richard Marcelo 25 -
-1
votes2
answers70
viewsSocket com Python
Hi, I’d like to ask for help on a project I’m doing. I wonder how I could get a python socket to "lock" a desktop program I made and only release that program for use when the server side allows.…
-
-1
votes1
answer222
viewsI want to scrap a page, but I can’t get a text that has " " on it
Well, the title says it all, I want to get the price of a product from the site https://www.pontofrio.com.br/, like this: <span class="nm-price-value"…
-
-1
votes1
answer379
viewsI want to convert Timedelta to float
I have a Dataframe in which one of the columns is the time interval in days between the search from one row to another, the data of this column are in the Timedelta form, as in the example:…
-
-1
votes1
answer66
viewsHelp with multiple Selenium Python Ivs
Friends, can you help me? I want to make web Scrap from a page and return all 8 texts from a span.text-Ellipsis. I made the following code: self.otherPlayers =…
-
-1
votes1
answer216
viewsPython sort list of dictionaries by key and value in separate orders
How to sort a list of dictionaries for example: nomes = [{'nome': 'joao', 'sobrenome' 'alves'},{'nome': 'joao', 'sobrenome' 'silva'}] In alphabetical order the names In reverse order, surnames that…
-
-1
votes1
answer340
viewsHow to publish a python application
Good afternoon: I am wanting to develop an application with python (Django) my concern is how I will publish my application (will be web), why python is interpreted, but I can’t send my fonts to…
-
-1
votes1
answer36
viewsCheck if number already contains in row and column
Good evening, I need to do a sudoku, and the first part is to print an array with random number from 1 to 9 and check if that number already has in the row and column. I did it: import random matriz…
pythonasked 5 years, 5 months ago spider tek 57 -
-1
votes1
answer37
viewsProblems with excessive search requests on google
During the development of a Python project that needs to perform several automated searches on Google. At some point, as expected, Google blocks requests declaring "suspicious activity". My question…
-
-1
votes1
answer70
viewsCan I create a list inside a python object?
have a question can I declare a list inside a Python object? If yes, I would do that, and how I would manipulate (add, print..) someone has some example or reference where they can study this? guy..…
pythonasked 5 years, 5 months ago andgualberto 27 -
-1
votes1
answer491
viewsAssign Linux environment variable in python
I need to read an environment variable in Linux, and store it in a variable in Python. I’ve tried it in many ways and failed. I started with this command, on linux $variavel='123123' x =…
-
-1
votes1
answer140
viewsInteraction with Tkinter Checkbutton widgets in python3
I am creating a system in python3 using the Tkinter library, I need that when checking the Checkbutton widget "Mark All" the others are marked and when unchecking, the others are unchecked. follows…
-
-1
votes1
answer219
viewsHow to escape the "{" character in a formatted string?
How would it be possible to make a string that uses the . format accept the use of keys as elements of the string and not escape it. Ex: I would like the variable s: interface = "alguma" s =…
-
-1
votes1
answer37
viewsIs it possible to add element to that list inside the for?
In an attempt to make python code smaller, I generated this list in enumerate. The problem is that it does not have a name. How could I add a new element or delete without having the list name to…
pythonasked 5 years, 5 months ago San D Erik 11 -
-1
votes1
answer558
viewsVscode ASCII Standard Sequences (ANSI)
I’m intending to migrate from pycharm to VS Code. It’s just that there’s something going wrong. Something that was enough as I use in pycharm to make the text more friendly, misses the use of…
-
-1
votes1
answer222
viewsPut except with bug name in python
I need to create a Try except, with two excepts, but do not know how to put the specific error in the first except, the error that appears this below, someone could help me? raise…
-
-1
votes1
answer65
viewsUrl checks - Django
When learning to develop applications using Django it is common to get the following URL: locahost:8000/minhaentidade/deletar/id However, a malicious user may change this id and end up deleting…
-
-1
votes1
answer679
viewsFilter elements from a tuple based on a value in a given index
I want to write a Python function, called separates, that takes a Tuplo whose elements are pairs (double 2 elements), where the 1st element is a name (a string) and the 2nd element is an age (an…
-
-1
votes1
answer260
viewsSelling and Controlling Stock (Python)
Give me a break. How do I input the input data to a pre-registered dictionary for the person using the program? Also, it can update the stock data, and automatically discount when the sale is made.…
-
-1
votes2
answers418
viewsname ' ' is not defined
def notas(): opcao = 0 while opcao != 5: n1 = int(input("Digite sua nota 1 :")) n2 = int(input("Digite sua nota 2 :")) n3 = int(input("Digite sua nota 3 :")) opcao = input("Deseja sair?") return…
-
-1
votes1
answer32
viewsSelect random mysql with Django
I have this code that selects randomly, users on my DB: def select_random(request): try: last = User.objects.count() - 1 index_one = random.randint(0, last) index_two = random.randint(0, last - 1)…
-
-1
votes1
answer59
viewsWhat does offset mean in Pillow?
The method getoffset() class PIL.ImageFont.FreeTypeFont returns a tuple. What exactly are these measurements? I use the Pillow in the version 6.1.0.…
-
-1
votes1
answer395
viewsPYTHON DELIMITER
How do I read a file containing data separated by period and comma appear in the table in Pyhton? Initially I have two txt files, I am using the pandas library I need to generate a txt third and put…
-
-1
votes1
answer203
viewsHow to create a Progressbar with Python and Pyqt5?
I’m having a little trouble creating a Progress bar, it’s actually about interacting with her because creating in yourself is actually easy: self.progressbar = QProgressBar()…
-
-1
votes1
answer307
viewsInput in multiple attributes of a Python class
Hello guys I’m having a question about multiple attributes of functions or methods through the function input. For example: class Pessoa(): def __init__(self, nome, idade): self.nome = nome…
-
-1
votes1
answer149
viewsIs it possible to receive real-time information from Chrome in Python?
Hello. I wonder if there is how to get information from the proxy that is available by default in Google Chrome (the developer tools) to the point that I can use it in real time in Python without…
-
-1
votes1
answer2035
viewsHow to find data based on another column with Pandas?
I own the dataframe dfa: id nome 1 jose 2 pedro 3 maria 3 maria 2 pedro 1 jose And a list with ids: ids = [2, 3] I want a dataframe dfb be the values of dfa filtered on the basis of ids: id nome 2…
-
-1
votes2
answers1378
viewsHow to calculate potentiation only using the sum operation?
I would have made a code that does multiplication from the sum, but I would like to know how I can make power by the sum, without using times(*). x = (input('Digite um número: ')) y = (input('Digite…
-
-1
votes1
answer68
viewsHow to perform a draw in python following a certain distribution, such as Gaussian or Maxwell-Boltzmann distributions?
My problem is to draw velocity values for a hydrogen molecule according to a Maxwell-Boltzmann distribution that will collide with an electron (with well-defined energy) and will split into two…
-
-1
votes1
answer40
viewsFunction that returns a new instance of a class
Can anyone explain to me why this function is not returning a new instance. It returns a monster object exactly as I want, but when the monster dies, the new instance it returns comes back exactly…
-
-1
votes1
answer469
viewsApplication with login and access control (Error: Typeerror: 'Nonetype' Object is not subscriptable)
I’m putting together a basic application with login and access control, that is, not all users can access the same windows. However I have a problem to load user information into the window after it…
-
-1
votes1
answer28
viewsProblems in the execution of a function
I was trying to create a Python function that would display only even numbers within a range of numbers, until it works and displays numbers, but it also displays 'None' where, I imagine, the odd…
-
-1
votes1
answer54
viewsPerform the reshape of different arrays
Hello! Follow down my doubt: array_a = [1,2,3] array_b = [1,2,3] array_c = [1,2,3] I’d like them to look like this: array_reshaped = [[1, 1, 1], [2, 2, 2], [3, 3, 3]] Could I perform this operation…
-
-1
votes1
answer41
viewsHow to use a variable as part of a command?
How can I use the value of a variable as part of a command? Example count = 1 tn.write(b'ip address 10.0.0.count 0\n') I would like the value 1 of the variable count is the last digit of the IP…
-
-1
votes1
answer192
viewsPython Convert XLS (2003) to XLSX
Good Morning! Guys, I have a directory with several spreadsheets exported from my system in XLS format (Excel format 97 - 2003), I need to write a script to go through this directory and convert…
-
-1
votes1
answer89
viewsUTF8 invalid codec in python
I’m using this code in the script: #! /usr/bin/env python # coding: utf8 import MySQLdb db = MySQLdb.connect(host="xxx.xxx.x.xx", user="xxxxx", passwd="xxxxxxx", db="xxxxxxx") cursor = db.cursor()…
-
-1
votes1
answer77
viewsWhat is the best way to check? (Try-catch, if multiples,...?)
I am reading thousands of XML files with python. The problem is, there is not always the field in all files. resumo_cv = root.find("DADOS-GERAIS").find("RESUMO-CV").get("TEXTO-RESUMO-CV-RH")…
-
-1
votes1
answer596
viewsRequest sending json
I’m trying to make a request for the python. Follow what I’ve tried: url = 'http://localhost:8080/detection/' headers = {'charset': 'utf-8'} response = requests.post(url, json=data, headers=headers)…
-
-1
votes2
answers136
viewsMake histogram in Python
Hello! I’m doing a histogram in Python, but in the line Histogram = Counter(decile(grids) for grade in grids) I find error with the Counter function. I already did the test using import Collections…
pythonasked 5 years, 2 months ago Mauro Junior 1 -
-1
votes3
answers194
views"break" does not finish execution as it should
Create a program where the user can enter several numerical values and register them in a list. If the number already exists inside, it will not be added. At the end, all unique values typed will be…
-
-1
votes1
answer580
viewsWhat would be the equivalent of while in python?
What would be python’s "do while"? Grateful!
-
-1
votes2
answers1177
viewsLimit number quantity in an input
I am making a basic program that reverses numbers (if the user type 123, the program returns 321), but the user can enter only 3 numbers, if you pass that the program has to ask the user to type…
pythonasked 5 years, 2 months ago Natanael Ricardo 47 -
-1
votes1
answer274
viewsHow to find out which program running in the foreground in windows, preference in python
Hello, I need to create a time counter that counts only when pycharm is open in the foreground, and other programs. How do I know which screen is being used in the foreground in Windows? I want to…
pythonasked 5 years, 1 month ago Jeferson Santos 42 -
-1
votes1
answer136
viewsHow can I generate an Integer number in python using Random
I have the following code and I need the result to be an integer type number, but it is returning a random value (number or None) with random type (int or nonetype) from random import randint def…
-
-1
votes1
answer1011
viewsHow to Uninstall an Entire Code at Once in Python
Since python is indent sensitive when Voce deletes a structure for example that sees that it will not use it anymore it starts to give error because the rest of the code is not indented as it…
-
-1
votes3
answers387
viewsI created a Python function, but it is not executed
I was studying about the Python language and, as a test, I played a game of Jokenpô. To make it restart, I saw that I would have to put it inside a function to eventually return to it and restart…
-
-1
votes2
answers176
viewsGet how many times each element of a list repeats
I have the following array: CLIENTE = ['MARIA','JOAO','MARIA','JOAO'] I’d like to do the following: {'MARIA' : 2, 'JOAO': 2} I tried to use the library from collections import Counter, but made a…
pythonasked 5 years, 1 month ago Luis Henrique 697