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
-
2
votes0
answers25
viewsDifficulty in execution
I’m doing a show Served in Socket Python using interface Tkinter, cannot exchange script information, to enter into the Tkinter. when I run both of them importing the socket I have no way to execute…
-
2
votes1
answer344
viewsJoin three similar codes into one
I am working with a table that shows the number of vacancies offered, candidates enrolled and enrolled in higher education courses. I want to make a program that allows the visualization of this…
-
2
votes1
answer179
viewsPython library
Is there a place where I can make queries about Python commands and functions in English? For example: If I wish to know information about a command or module like numpy or pandas ? I noticed that…
-
2
votes2
answers953
viewsHow to use strip() next to a list or tuple in python?
I am creating a script and in a snippet I create a list and then use the strip() function next to the upper() inside the v1 input, but when calling the script and executing it does not return…
python-3.xasked 6 years, 7 months ago Harry 709 -
2
votes2
answers11769
viewsProblem when calculating percentage (result is always "0")
I finished a program in Python (perfected with a response obtained right here in Stack Overflow), but I’m trying to include a percentage calculation that isn’t working. Although everything else…
-
2
votes3
answers3080
viewsCheck the line containing a string inside a TXT file
I need help with a program that reads a file and responds to me on which line contains a string inside it. Example I have a file . txt and inside it I have 5 lines: File.txt: arroz batata feijão…
-
2
votes2
answers1322
viewsI understand a parallel run using Fork. How does Fork work?
import os def filho(): print('Ola do filho', os.getpid()) os._exit(0) def pai(): while True: newpid = os.fork()# fornece ID para um novo processo! if newpid == 0: filho() else: print('Ola do pai',…
-
2
votes3
answers3778
viewsCount the most popular words
I’m trying to find the number of occurrences of a list of words in a text: from collections import Counter def popularidade (texto, palavras): texto = texto.lower().split() palavras =…
-
2
votes1
answer721
viewsHow to call a class attribute in another Django class
I’m trying to create classes that will relate in a certain way. The idea is to be a game in which the player will have some options of choice and then your score is based on the score of your…
-
2
votes1
answer1889
viewsHow do I filter data by date on a dataframe (Python)
Since you would have to create a new dataframe with the information coming from these dates below. import pandas as pd import numpy as np import datetime %matplotlib inline races =…
-
2
votes2
answers789
viewsReplace all characters in a string with another character
def getGuessedWord(secretWord, lettersGuessed): secretWord_copy = "" for i in secretWord: print(i) secretWord_copy = secretWord.replace(i," _ ") print(secretWord_copy) secretWord = 'apple' I’m…
-
2
votes2
answers1406
viewsRounded Tkinter button
Is there any way to round the button tips? Or even leave it as a circumference? Like this one for example:…
-
2
votes2
answers399
viewsCan you replace commands with variables in python?
I’m having a doubt, is it possible to store commands in variables? For example: X = while X(True): So I could facilitate some things in some scripts, or kind of trying to "create" a language of my…
python-3.xasked 6 years, 6 months ago Caio Cristiano 63 -
2
votes2
answers343
viewsString occurrence calculation in list - Python
Staff need a help to calculate the amount of occurrences of a given string in a column of a list. Example: lista_teste=['Name','Age','Sex','Profession'],['Peter','25','Male','Physician']...] Ex:…
-
2
votes1
answer205
viewsGet input value
Hello I would like to know how I can get a value from a one-page input after performing a Curl with requests in python 3.6! Example: <input type="hidden" name="authURL"…
python-3.xasked 6 years, 5 months ago user113606 -
2
votes1
answer107
viewsHow to import packages within other subpackages in Python?
I have the following structure on a project PacoteRaiz/ __init__.py Pacote1/ __init__.py Modulo1.py Pacote2/ __init__.py Modulo2.py If I want to use some function that is inside Modulo1.py in…
-
2
votes2
answers130
viewsDatetime without the year
I need to represent holidays and in my holiday class I need to set the start and end date of the holiday. As start date and end date I need to inform only the month, day, hour and minute. But the…
-
2
votes1
answer216
viewsSingle lists with at least 2 difference elements
Considering the numbers: 01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25 How do I generate lists of 15 items (numbers cited above), and they need to have at least 2 items…
-
2
votes0
answers166
views(Socket) Client and Server Connection - how to get Cmd-> Client (Python) return
I want to execute a command in the client’s Cmd and return the values to the server. I Already Managed to Execute the command in the client’s Cmd... Now how do I return the values to the server? The…
-
2
votes2
answers9963
viewshow to compile a python script in a executable
How best to compile a python script for an executable running on a linux (Ubuntu), windows and mac operating system.
-
2
votes2
answers1256
viewsClient and server programming: How to achieve numerous data exchanges per client and multiple clients simultaneously?
The client: from socket import * serverHost = 'localhost' serverPort = 50007 # Menssagem a ser mandada codificada em bytes menssagem = [b'Ola mundo da internet!'] # Criamos o socket e o conectamos…
-
2
votes1
answer812
viewsComparison of values in python Tuples list 3.x
My doubt is how I can interact on this list to make comparisons between values. def trocar(vals, posX, posY): temp = vals[posX] vals[posX] = vals[posY] vals[posY] = temp return None def…
-
2
votes3
answers465
viewsTest sum function
Hello everybody all right? First I want to say that it is a pleasure to be part of this community. I’m studying python on my own, I found a course per application, I’m already in the functions part…
-
2
votes1
answer559
viewsWhy does this 'sys' is not defined error occur?
Why does this error occur name 'sys' is not defined? while True : print ('Digite exit para sair') response = input () if response == 'exit': sys.exit() print('Você digitou' + response + ',')…
python-3.xasked 6 years, 4 months ago Ismael dos Santos Cardoso 33 -
2
votes1
answer112
viewsImports within Python functions
I have seen cases where the developer does the import of a module within a function, some cases mainly in the Django documentation, why it is not very clear to me, if anyone can help me thank.…
-
2
votes1
answer83
viewsPython dunders __copy__ e __deepcopy__
I’ve seen it in some codes, especially Django dunders __copy__ and __deepcopy__, the idea by traś them I understand that provide copies of the object, but usually the dunders can be called…
-
2
votes1
answer332
viewsCheck url after request
How do I make my code check which url/link is in ? My code: import requests as r from bs4 import BeautifulSoup as bs import time import os clear = lambda: os.system('cls') clientes1 = 0 clientes2 =…
-
2
votes2
answers445
viewsHow to concatenate value to a column of a table in csv?
I’m having a hard time creating an algorithm that adds an element to the third row in the CSV file in the Python language. The file has following data: Serial; Imei; Número; Icc; Stock…
-
2
votes3
answers2206
viewsHow to not return a None value in Python?
I have the following example code: lista = [100,200,1000,3000,2,3,4,5,6,7,8] def regras(x): if x < 100: if x % 2 == 0: return x if x >= 100: return (x+x) v1 = list(map(regras,lista)) print(v1)…
-
2
votes1
answer95
viewsProblems with incorrect data in a dataset (using Pandas)
I have a dataset called Auto.csv, which has the form: mpg cylinders displacement horsepower weight acceleration year origin name 18 8 307 130 3504 12 70 1 chevrolet chevelle malibu 15 8 350 165 3693…
-
2
votes1
answer1199
viewsProblem with arrays in Python 3.6
I started a small course on deep learning with Python, but I ended up having a problem with arrays... I usually take the code from the class and modify it a lot before creating an original, but this…
-
2
votes1
answer174
viewsString search with character "|"
I need to perform a query in a txt file in Python, but I have 2 problems due to interpretation of special characters. When I insert | or \ the result is replaced: the | is addressed as white space…
-
2
votes5
answers691
viewsMethod Reverse returns None
I’m applying the method reverse in a list and the same returns None. Ex. teste = ['audi', 'subaru', 'fiat', 'ford'] print(teste.reverse()) None…
-
2
votes2
answers196
viewsMultiplication and division result with two boxes after the comma
Hello everybody all right? I’m doing an activity for my python course, it’s a script that basically calculates the area of a wall in meters and tells how many liters of paint will be used. The…
-
2
votes1
answer239
viewsIs it possible to inherit a python class without writing all attributes in the definition?
I have the following example code: from Testes import POO class Fisica(POO.Cliente): def __init__(self,sexo,nome,idade): super().__init__(nome,idade) self.sexo = sexo Note that the name and age…
-
2
votes1
answer175
viewsProblems to develop a Bricks Breaking-style game on Tkinter (collisions with objects)
I’m a few days studying and trying to get the ball to hit the rectangles from above they fade and invert the side from tkinter import * from constantes import * import random class Jogo(): def…
-
2
votes1
answer51
viewsTime leaving with unexpected result
I’m running a code that prints the hours on the terminal but when I use the code below it brings me a totally wrong value on time: Code: from time import gmtime, strftime print(strftime("%a, %d %b…
-
2
votes1
answer1686
viewssklearn’s classification_report and confusion_matrix: do the values not match?
Model: logistic regression with sklearn. I decided to compare the results shown in the classification_report, calculating them using the confusion matrix but apparently the results do not match:…
-
2
votes1
answer7298
viewsHow to save in CSV or Excel a table generated from another table with pandas or pivot table?
I have a table with data of several years from 2000 to 2015 in CSV format. In my code I ask the user to enter a year he wants to see and return on the screen only the years he requested. Ex.: 2000.…
-
2
votes2
answers1413
viewsRemove blank lines in a csv
I am trying to remove empty lines from a csv document: Document: phrase, .,pt .,en .,en .,it .,es .,pt .,pt .,es .,pt .,pt "it’s not Expensive",en "casi 50 euros la alfombra es cara", " the price…
-
2
votes2
answers206
viewsReplace words between two files
I’m trying to do some overwriting between two files: if a word from file 1 is in the second column of file 2, replace that word from file 1 with the word from the first column of file 2 File 1:…
-
2
votes1
answer192
viewsProblems with __eq__, __lt__, etc. and the method removes from the list object
I’m having the following problem, I have a letter class and use the magic methods eq, ne, le, it’s, ge, gt to be able to compare the value of two cards and also to be able to use the Sort function,…
-
2
votes2
answers5334
viewsHow to check the versions of the modules installed in Python?
I installed two modules in Python via anaconda (Conda install): zipfile36; Mysqldb. Using the anaconda prompt I can get the version of both and all my other modules using the command: conda list But…
-
2
votes2
answers551
viewsstring manipulation python
I am having a problem regarding python b (Backspace), instead of deleting the previous character, it generates a "•" as the image below: Follow the line of the code that generates this return: #-*-…
-
2
votes1
answer899
viewsConvert Days & Time (Hours x Minutes x Seconds) to Time only
I have a Dataframe in which I am making the difference between two different dates to get the difference in Hours and Minutes, for example: data_inicial = '2018-07-03 16:03:00' data_final =…
-
2
votes2
answers1229
viewsCatch tags within tags in Beautifulsoup
I have the following situation: <a href="https://g1.globo.com">Globo</a> <h3 class="b"> <a href="https://www.google.com">Google</a> </h3> Using Beautifulsoup, as…
-
2
votes2
answers254
viewsIntensive python course by Eric Matthes ex8.10
I’m having difficulty doing an exercise of the book 'Eric Matthes' intensive python course the exercises is as follows: 8.10 - Great Magicians: Eat with a copy of your 8.9 exercise program. Write a…
-
2
votes1
answer580
viewsbreak list by python size
Today I came across the need to break a list of over 100 values in a list of lists with a maximum of 100 values. I researched a lot, and in the end I put together the function: remove_list=[[]] n=0…
-
2
votes1
answer2244
viewsConvert Python to exe
I have an app made in python that pulls several Imports, and my client does not want to install Python in his environment (because it is an Oracle server), the output I found was to create one . exe…
-
2
votes1
answer608
viewsWhat does the class name mean in super(). __init__()?
How the name of the classes inserted within the constructor’s parentheses works __init__( ), in the classes Telefones, TiposTelefone and Agenda? This is only an excerpt of Chapter 10 code from the…