Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes2
answers558
viewsImports into __init__.py file
I’m studying the documentation of Django and noticed that in some files __init__.py there are imports, I know the archive __init__.py defines a module but do not understand why imports in it.…
-
1
votes0
answers853
viewsTypeerror: importPoisson() takes 1 positional argument but 2 Were Given
I am trying to import from an external file some data to be able to generate a graph and such, but every time of this error, follows my code: They may also say bugs you found in my code that can be…
-
1
votes1
answer1784
viewsPandas: Create multiple columns in Dataframe
I have a spreadsheet with the following information: NUM_LEGISLACAO DSC_URL ... COD_TIPO DSC_TIPO 0 323/1895 NaN ... 2.0 CONCRETO 1 2.269/1896 NaN ... 2.0 CONCRETO 2 2.397/1896 NaN ... 2.0 CONCRETO…
-
1
votes1
answer990
viewsHow to make the label background transparent ? python3 + Tkinter
lbl2 = Label(jan, font=("Arial", 12, "bold"), text="Escolha apenas uma Categoria por vez") lbl2.place(x=20, y=450) I’m putting this label on top of a green image, but it ends up with her background…
-
1
votes1
answer48
viewsFind substring with REGEX
I am trying to turn all parts N_(...) into uppercase. I thought REGEX would be the most appropriate. It’s just too hard to even capture the N_(...) part and then turn it into capital letters I can…
-
1
votes1
answer565
viewsProblem with Geometry pack and grid (Tkinter)
to tell the truth these two geometries are very complicated, but unfortunately I need to use this 2 in this project. So come on. first follows the code: from tkinter import* from tkinter.ttk import…
-
1
votes2
answers7309
viewsHow to concatenate items from a python list?
Let’s say I got the result of a list: ['_', '_', '_', '_', '_', '_', '_'] how can I turn her into this?: ['_ _ _ _ _ _ _'] Or even in a variable with the above value…
-
1
votes1
answer698
viewsPython Connect Sql With user and "token"
I have an application in Flask and am using Sqlalchemy to access SQL Server. I would like the connection to the database to be made by a generic user and the password is a "token", I thought it…
-
1
votes1
answer128
viewsSyntax error in Python 3.7
I am practicing a course exercise and came across the following error below. I am using Python 3.7. What’s the problem with this typing? convite = 'Flavio Henrique Almeida' parte1 = convite[0:4]…
python-3.xasked 6 years, 1 month ago Jaqueline Karina 21 -
1
votes1
answer200
viewsError running PIP command on Docker
I have a python project that runs inside a Docker. When the image (Build) is mounted rele da um RUN pip install -r requirements.txt but when it executes the command returns a connection error.…
-
1
votes0
answers67
viewsError running setup.py on Pycharm
Hello, every time I try to run a file setup.py find the following error: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py…
-
1
votes1
answer262
viewsConstructor method in inheritance classes
Using Python3, as would the constructor method of the class Z? class W: def __init__(self, atributo1): self.atributo1 = atributo1 def metodo1(self): print("Metodo1") class X(W): def __init__(self,…
-
1
votes0
answers64
viewsdo a while loop or restart the program on Tkinter with new question
I would like to know how to do when click the reply button, restart the program with a new account and optimizing the code? from tkinter import* from random import randrange janela=Tk()…
-
1
votes2
answers106
viewsPython - libraries without import "*"
How do I create a library without having to matter like that: from x import * or from x import y? Only by importing import x. Who will answer me, please use the script below as a library example.…
-
1
votes2
answers671
viewsSelect in Python (with BD: Postgres)
I am unable to select in the Postgresql database. Python 3. conn = psycopg2.connect(host="localhost", dbname='postgres', user='postgres', password=postgres) cur = conn.cursor() cur.execute("select…
-
1
votes2
answers697
viewsHow to add list values?
I have a list of lists, and I wanted to add up the various values for the Indice 3 of each list, but only if there is a certain string in this list. How can I do? For example I have this list:…
-
1
votes0
answers132
viewsCompare a specific string in a python field
The purpose of the code is to try to find the string 'WCDMA FDD Band I' in the column device_2['Band']. If so, it should dial 'YES' in the field device_2['WCDMA FDD Band I'] and otherwise it should…
python-3.xasked 6 years, 4 months ago João Lucas Flauzino 11 -
1
votes1
answer3835
viewsRead specific line of a txt file
I have a file of 1000 lines and I want to read line 952. I don’t want to have to use a loop to go through all these lines, there’s some more optimized way to do this?
-
1
votes1
answer2542
viewsAdding elements from a list to a dictionary in Python3
Good afternoon, I’m having trouble adding elements of a list to a dictionary. The list elements to put in the dictionary are: ['Joao', '83889023', 'Maria', '81944356', 'Marcos', '32258899', 'Ana',…
-
1
votes1
answer244
viewsCrossing lists in python
Good evening, I’m breaking my head to find the error, is the following I’m crossing this list of binary numbers, the first crossing is working but the second is getting the end of the first, to…
python-3.xasked 6 years, 4 months ago Patrick Amaral 88 -
1
votes0
answers49
viewsPython sniffer only gets multicast address 224.0.0.1
Hi I’m trying to make a Sniffer with Python and when I use my smartphone it only gets the address of multicast 224.0.0.1. How do I get the ip of the site I’m visiting on my smartphone? On my laptop…
python-3.xasked 6 years, 4 months ago Gabriel costa 11 -
1
votes1
answer185
viewsError finding the center of an Opencv Python object
Hello, I am studying opencv to use in a drone and while I was implementing a code of a tutorial that detected objects and drew a circle in the center of it, and for that you should take half the…
-
1
votes0
answers51
viewsBCG graphics in Python.
Friends, is there any way to make a chart as below using Python/Matplotolib? Thanks for your help. I observe that I researched a lot about the subject, but I am finding difficulty, mainly in the…
-
1
votes2
answers56
viewsIf block is not well located, how to solve?
I did so, by the way he’s making a mistake, because door 80 is open and he returns as closed import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server = '201.27.188.138' port = '80'…
-
1
votes2
answers326
viewsData analysis with python list
I have a txt list with the following data: txt list. AC;12;733559;8476515;11.57 AL;27;3120494;24574808;7.87 AM;13;3483985;59779292;17.17 AP;16;669526;8265965;12.36 BA;29;14016906;154340458;11.01…
python-3.xasked 6 years, 4 months ago Sandson Costa 509 -
1
votes2
answers6913
viewsCounting Nan and null values in a pandas dataframe
Imagine we have a CSV file called.csv data: col1 col2 col3 col4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 33 44 import numpy as np import pandas as pd po = pd.read_csv('/dados.csv') My goal is to better…
-
1
votes1
answer38
viewstranformative
def eR(k,x): if k<=1: return 1 else: return (x**k)/eR(k-1,x)*k x=int(input("Insira o X:")) k=int(input("Insira o número de…
-
1
votes2
answers220
viewsFlask Sqlalcheny Typeerror: 'Fermentables' Object is not iterable
In the model FermentableTypes: class FermentableTypes(db.Model): __tablename__ = "fermentable_types" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(50)) desc =…
-
1
votes3
answers126
viewsFormal definition of operations = and ==
What is the formal definition of the use of = and of == in Python? I can identify in the examples when I have to use which, but when I try to identify these operations by a formal definition as…
-
1
votes4
answers658
viewsDebug showing variable name and value?
Often when I need to debug the value of a variable at runtime I use the print(). But when there are many variables, I need to identify the variable name along with the value. In this way, the print…
-
1
votes0
answers29
viewsMultiple search factors in an html file with variable parameters
Good morning, everyone. Needed to search by the name of the presidents of brazil, in html files. I created a json with the names of the presidents to facilitate. Follows the code: # !/bin/env python…
-
1
votes1
answer130
viewsHow to create a "trigger" function when a variable changes value?
Watching pygame.Surface.get_rect(), I realize that when I change a variable, for example left, pygame automatically recalculates all class variables (center, right, etc.). I’d like to know how it’s…
-
1
votes1
answer819
viewsHow to set the xticks equal to that figure
I’m taking a course in Python geared towards finance. Then in an exercise you are asked to plot a graph using Dataframes. So far so good, I managed to do everything right, however my xticks do not…
-
1
votes0
answers297
viewsHow to find out which services are running on a python port?
I would like to add my question to that code: #!/usr/bin python3 # coding: utf-8 import argparse import socket import os import sys def Logo(): print (''' ______ ____ __________ ___ / / /_ \/ /__…
-
1
votes1
answer54
viewsDoubt regarding the Python syntax
Good evening guys, my question is about a piece of code I found in a book about Python and Opencv. The author created the function that I will put below: @property def frame(self): if…
-
1
votes1
answer339
viewsAbort a specific Thread
How do I interrupt a specific thread? for example: from _thread import * from time import sleep result = 0 def soma(nome, numero, delay): global result while True: result += numero print('{}: {}…
-
1
votes1
answer1437
viewsAttributeerror: __enter__ in context manager implementation
I’m trying to understand the workings of gerenciadores de contexto Python, implementing a contextmanager. Here follows the script: class contextmanager(object): def __init__(self, func): self._func…
-
1
votes1
answer226
viewsHow to detect a click or other mouse event in win32gui’s Notifyicon?
I’m trying to modify the library win10toast so that I can pass a callback that runs when the user clicks on the Windows 10 notification that I show. The "meat" of the library, which I’ve mastered as…
-
1
votes2
answers941
viewshelp with storing value of a local variable in python
Hello, well, I am writing an application using SQLITE and Python, everything was going well until I had a problem that I am not able to solve, it happens that I have a db of the fipe, so I need to…
-
1
votes1
answer149
viewsCircular import
To doc of Flask, despite using in its examples, warns at the end of the page about the bad practice of using circular imports. Another thing that bothers me is creating "global objects" inside a…
-
1
votes1
answer1266
viewsHow to add elements to the tuple using a function?
def funcao(): int(input('insira um número:')) tupla = (funcao(), funcao(), funcao(), funcao()) print(tupla.count(9)) print(tupla) insira…
-
1
votes1
answer1547
viewsmultiple commands with python subprocess
I am developing a system (college work) that consists of a website for the use of a certain board. The problem is that to run the code on the board, I need to run a bunch of commands. Currently my…
-
1
votes0
answers37
viewspython sigint and Ctrl c have different effects
Hello, I need to run an executable done in c,this executable performs operations on a board and writes to a file, the problem is that the write event occurs when the program receives a Ctrl+c. I…
-
1
votes2
answers3000
viewsPrinting data from a Python dictionary
How do I print the data of a dictionary each in a column? For example: lanchonete = {"Salgado":4.50, "Lanche":6.50,"Suco":3.00,"Refrigerante":3.50,"Doce":1.00} for m in lanchonete: print (m[0]) I…
-
1
votes1
answer265
viewsStandalone Python software ( .exe file) for non-python machines with GUI and Tkinter
I am developing a software using Python 3.6.5 and I need to run it on machines that do not have python installed. It contains some libraries for machine Learning and access and excel to MS. I have…
-
1
votes0
answers549
viewsChange screen by python file in kivy
I need to change the screen inside the file .py, I can’t do it for .Kv because I have to use the ButtonBehavior and it does not work in .Kv. from kivy.app import App from kivy.uix.boxlayout import…
-
1
votes2
answers126
viewsPython Pandas - How to check if a "tuple" of two Series elements is contained in a set?
I have a "set" of "tuples" as follows set = {(2, 3), (2, 4), (5, 5)} My Dataframe is like this: df = pd.DataFrame( {'one': [1,2,4,1], 'two' : [5,3,2,2]}) I want to check if in each row the "tuple"…
-
1
votes3
answers840
viewsReplace word list in text
I always have a hard time with replace and sub. I know how they work, but with me it’s never right. I have a list of words and am trying to replace these words in a text: Text: Brazil, officially…
-
1
votes1
answer58
viewsHow do I call file.Setter using Python to normalize the path name
Code: class Arquivos: @property def file(self): return self._file @file.setter def file(self, arquivo): if arquivo: self._file = os.path.abspath(arquivo) Calling for: Arquivos.file('usp/dados.json')…
-
1
votes1
answer974
viewsHow to insert a try counter within an exception (except Valueerror) of Python 3
Hello. I am a beginner in programming and have been trying to develop on my own programs that I learned in programming book exercises. I made my version of the classic "Guess the number", where the…