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
votes1
answer56
viewsPython recursive function printar correctly
I am starting in python and I would like the result of my execution to be as follows: [ [ 0 , 1 , 2 ] , [ 3 , 4 , 5 ] , [ 6 , 7 , 8 ] , [ 9 ] ] [ ’ ∗ ∗ ∗ ∗ ’ , ’∗ ∗ ∗ ∗ ’ , ’ ∗ ∗ ’ ] But I’m not…
-
1
votes1
answer42
viewsWxpython: Getfocuseditem() returning item even with nothing focused
I’m writing an interface with wxPython, but I’ve come across a problem so far with no solution, even looking at the documentation. I have a Listctrl with several items that should be sent to the…
-
1
votes1
answer39
viewsPython 3x - Error: "Object" is no defined in list
I am learning to program in python and I have this following problem in an exercise. When running the code happens this following error: vogal = (a,e,i,o,u) NameError: name 'a' is not defined. I…
-
1
votes1
answer110
viewsUpdate on Timefield Django 2.0
I have a model with several fields, one of them is the Timefield type: class Venda(models.Model): id = models.AutoField(u'AÇAIEX', primary_key=True) hora_saida = models.TimeField(max_length=6) To…
-
1
votes0
answers88
viewsPython - How to organize an excel line from python?
Hello, this is my first question here, I don’t know if I’m asking you correctly, but come on. From the "Concat" functionality of the pandas package, I am joining several excel files, the code that…
-
1
votes2
answers138
viewsHow to be more cautious when using the Eval function?
I have a function that gets an account and calculates it using the function eval. My question is, how can I be more cautious in using this function ? def calcula(string): if type(eval(string)) in…
-
1
votes1
answer360
viewsHow to limit the number of threads running at the same time?
I’m trying to create a proxy checker using multithreading, this is my code: import requests import threading from time import sleep from colorama import Fore url = 'http://google.com' proxyList =…
-
1
votes1
answer357
viewsCheck existence of Python file with function
I searched all the repositories corresponding to my doubt here, but all are very direct when creating and reading part of files in Python, but I saw nothing related using function. Function to…
-
1
votes1
answer36
viewsProgram that calculates a series of N terms
Write a program to calculate the value of the series, for N terms. S = 0 + 1/2! + 2/4! + 3/6! + ... I started to do the program as shown in the code below, but I’m not getting the right result.…
python-3.xasked 4 years, 5 months ago Tryford 41 -
1
votes0
answers11
viewshow to return the contents of a json to flask
I would like to return the content of a json file that is on my machine in an endpoint,basically I have a file with citations and I would like to return the content of that file in an…
-
1
votes0
answers32
viewsSelect multiple in Python and Django
I have a class Lancamento and a class Plano de conta. Plano de conta is a secondary Launch key, ie I register account plans and when registering a launch I select an account plan. For that, I did so…
-
1
votes2
answers335
viewsHow to open a second window in Pyqt5 without closing the main?
I am creating a login interface, and I want when the user presses a button, to open a new window in Pyqt5 but without closing the main window, but the secondary window is not staying open. from…
-
1
votes1
answer77
viewsMy Ry is not reading my except
while True: try: idade = int(input(f'Digite a idade da pessoa {c+1}: ')) except ValueError: continue else: if idade < 18: listaidademenorde18.append(idade) elif idade >= 18:…
-
1
votes2
answers264
viewsHow to round decimal numbers to the largest integer? python
I’m in need of arredondar values decimais for the highest integer value mais próximo of the relevant value. For example, I have the value... 22.6 ...and would like to receive as a result the…
-
1
votes2
answers6846
viewsHow to cut string text in python by delimiting the initial substring to the final position?
I would like to know and understand how to return the cut in text with offset. I’m a beginner in python and I’m currently on a project to migrate from Delphi to python and there are a few things I’m…
-
1
votes2
answers120
viewsError in Python script
Good afternoon Can someone explain to me why my code does not give the requested result and what I can do to obtain the requested solution? Error appears as follows: total =…
python-3.xasked 5 years, 6 months ago user99237 -
1
votes2
answers2087
viewsHow to draw numbers from a list, randomly and without repetitions?
How do I draw 9 numbers in a list of 15, without repeating the numbers drawn? I use Python 3.8. import random for c in range (1, 16): n1 = str(input("Digite um nº: ")) l = [n1] random.shuffle(l)…
-
1
votes1
answer437
viewsHow to import a function from a module in Python?
I’m having trouble importing the function of a module and making use of it. I already made sure to put the file __init__.py folder. But I can’t make use of the functions. The program will download…
-
1
votes2
answers177
viewsPrinting of Matrices in Python
I’m starting in python and I need to solve several Python matrix exercises, but I can’t make the right impression. Understanding the Logica of this exercise I can solve the other quiet. Could…
-
1
votes0
answers357
viewsImport . csv file with Python/Django
models TIPO_PESSOA = [ ('PF', 'Pessoa Física'), ('PJ', 'Pessoa Jurídica'), ] class Pessoa(models.Model): nome_razao_social = models.CharField(max_length=255) tipo_pessoa =…
-
1
votes0
answers15
viewsProblem reading . csv in Python/Django
I am trying to create a new person from a .csv. file My code is as follows:. models TIPO_PESSOA = [ ('PF', 'Pessoa Física'), ('PJ', 'Pessoa Jurídica'), ] class Pessoa(models.Model):…
-
1
votes1
answer252
viewsSee which elements of the list are primes
Hello, I am making a list of exercises and I came across a question consisting of reading the elements of a list and determining how many are cousins. I could only do the function to calculate the…
-
1
votes3
answers4131
viewsJoin columns in python?
Hello. I have this file (filing cabinet) where I need to merge the columns yyyy, mm, dd, hour (year, month, day and hour) into a single column, and stay in this format 20180101010000, conclusion:…
-
1
votes0
answers22
viewsHow to extract bold or italic characters from a docx?
Have a docx of articles published in marketing magazines that contain scales and would like to extract them. For example, with the following scale, I would like to get the title: Ten-Item…
python-3.xasked 4 years, 2 months ago Revolucion for Monica 159 -
1
votes0
answers32
viewsNew python operator 3.8.5
Python 3.8.5 added operator :=, I wonder what it’s for
-
1
votes2
answers2495
viewsHow to make an array with attributes or objects of a class?
Good evening, I’m a beginner in python and I have a question about how to make an array of an object or class. My main program contains a function that cuts into text, delimiting blocks and so on.…
-
1
votes1
answer21
viewsWhen a repetition is made in case there is no answer, no change is made! pq?
It’s a simple code, but based on what I’ve seen and been studying about repetition structure right here, I’ve come up with a way to do it, but I’m dealing with the following problem: the value is…
-
1
votes1
answer76
viewsHow do I use a virtual keyboard in a Kivy or Kivymd application?
I am developing an application in python with graphical interface made in Kivymd. My question is the following, when I click in some field textinput I want a virtual keyboard to appear so I can…
-
1
votes0
answers46
viewsFile upload with HTTP-POST
When running the script to send the file it returns me this message. Traceback (most recent call last): File "modelo.py", line 102, in <module> filepath = args.filepath AttributeError:…
-
1
votes3
answers193
viewsTake values less than or equal to 500 from the list - Python
Code: acid_vit_lista = [100,500, 200, 230, 400, 500, 600, 700, 900, 2000, 1100] acid_vit_dig = int(input('\nNumero de acidentes de transito: ')) res_acid = (acid_vit_lista[num_dig])# num_dig foi da…
-
1
votes1
answer123
viewsDisplaying only integer values on X-axis in matplotlib chart
I would like to show X-axis only integer values of K: k in range(20) import matplotlib.pyplot as plt %matplotlib inline X = [k for k in range(20)] y = rmse_val plt.plot(X,y,color='green' ,…
-
1
votes2
answers237
viewsHow to get the name of the python function parent
Fala, Povo! I have a log - add_log() - add function that takes a title, status and Obs to register in a txt file along with the time. I wonder if there is any way to get the name of the parent…
-
1
votes0
answers92
viewsProblems in the Results print()
I’m writing a code that calculates probabilities based on a particular Excel database. When doing this in Excel I have the final result in the column "Probability3 %": Now I need to do the same, but…
-
1
votes1
answer58
viewsIMPORT ERROR - No module named dlib
I installed dlib, opencv and Pillow through Anaconda, creating a enviroment, but when I will import dlib the following error happens: No module named dlib. I’ve already deleted the interpreters and…
python-3.x opencv dll artificial-intelligence pycharmasked 5 years, 5 months ago Marcos Paulo S. Rezende 351 -
1
votes2
answers193
viewsCapture Json information using Python
I am working with the SWAPI API with Python and find the following difficulty: When I get the information from a Json, Dict is returned when I access the key search, I get a list, but I cannot get…
-
1
votes1
answer21
viewsDoubt Python 3 Selecting items from a dataframe
Good evening everyone, all right? I’m new to Python and I was doing some exercises where I needed to select some information from a database. In one of the subitens, the correct code was:…
python-3.xasked 4 years, 1 month ago Thiago Sereno 11 -
1
votes4
answers361
viewsHow to count occurrence of strings within a dictionary made up of lists in Python?
I have a satisfaction research dictionary that the evaluator can evaluate up to 6 products. The program stores the evaluator, the refrigerant and the note for the refrigerant. And I have to show the…
-
1
votes1
answer174
viewsMy Python code works, but I don’t understand why an int()
I did a time-calculation program on medications. According to the calculations everything is running perfectly, but I did not understand a detail, why the need to use a int() at a certain point in…
-
1
votes0
answers26
viewsSwitch windows in wxpython without destroying the previous one
Good afternoon, I’m new to Wxpython and I’m only trying to have the "frame1" registration update the window to the Mainframe that will mount a Pie Chart. I don’t want the window to be destroyed,…
-
1
votes2
answers53
viewsBrowse and collect data from dictionaries within a list
I have a list of several dictionaries containing registration data: [{'sex': ’M', 'age': 44}, {'sex': 'F', 'age': 33}, {'sex': ’M', 'age': 55}] I created separate functions to calculate the average,…
-
1
votes3
answers155
viewsHow do I remove the last "," that appears in the print?
How do I remove the last , that appears in the print? x = int(input()) z = range(x) for i in z: n = 2**i print(n, end=", ") When I run the show he returns it to me: 1, 2, 4, 8, 16,…
-
1
votes0
answers17
viewsHow do I check if a key has been pressed in Python
Hello I am developing an algorithm to make a scrolling of Dungeons & Dragons plug, and as much changes in the plug I wanted to make a scheme where by pressing some key I could modify some value,…
-
1
votes2
answers469
viewsInsert header in Python worksheet
I need to insert an image into the header of the xlsx file that is generated by Python with a routine of capturing database data and turning it into report. I’m using this alternative method, where…
-
1
votes1
answer76
viewsHow to load whole values from a txt file? - Python
I want to load a dictionary where the text file .txt contains information of the type String, but I want the values to be loaded Inteiro. {'11322567498': '[0],[0]'} Note that values are always being…
-
1
votes2
answers168
viewsWould you like to make a code that spells out the word?
I’m new to programming and I’m trying to put together a script where I type in a word and he spells it out for me! I’ve assembled the following code! nome = input('palavra para soletrar:') while…
-
1
votes3
answers16188
viewsRemoving lines from a dataframe that meet a certain condition
Hello, I am trying to manipulate a dataframe by python 3.x API pandas with some data to be analyzed, and I need to remove the lines that meet certain conditions. The dataframe has the following…
-
1
votes2
answers55
viewsHow to catch the smallest hints from the list, but only from Dice 0 to 1
z = [-4, -1, 0, 0, 0] F1 = [ 9, 1, 1, 0, 18] F2 = [ 3, 1, 0, 1, 12] #Pega a posição do menor valor das listas n_min_z = min(z) n_min_F1 = min(F1) n_min_F2 = min(F2) #Guarda a posição em uma variavel…
-
1
votes1
answer294
viewsGenerate PDF in Django admin
How do I get a PDF in the Django admin? I already have the views, I can generate in the frontend with HTML all right, but how do I put a button in the admin to generate or redirect to the pdf link?…
-
1
votes1
answer120
viewsMove aquifers by extension, PYTHON
Good afternoon, I want to fine tune my skills in PY, and I’m in a small script to move files from one place to another, but I would like to do this and not be guided by the name of the file, but…
-
1
votes1
answer153
viewsNon-blocking execution with asynchronous Python functions
I want a certain flow to continue even calling a async.sleep() in the code, I have the following code import asyncio async def funcao_1(name): print("entrando no sono...") await asyncio.sleep(3)…