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
answer950
viewsHow to return data from a select in sqlite3 as dictionaries instead of tuples in Python?
I’m using sqlite3 to record some data. However, by default, when a select is made, it returns the information as a list of tuples, which is considerably harder to work with than if they were…
-
1
votes1
answer91
viewsDoubt def function with tuple mode input
Good person I have the following code: def tuplas(x): return x[::2] tuplas(('Hello', 'World', 'estamos', 'vivos')) This code will work perfectly, but if I remove the parentheses of my tuple,…
-
1
votes1
answer599
viewsError "No module named 'pytube'"
When installing a package using PIP I cannot use it. Example: pip install pytube So far so good, down easy# In the IDLE: import pytube Upshot: Traceback (most recent call last): File…
-
1
votes1
answer1552
viewsPython administrator privileges
Is there any way or command to run a Python script with administrator privileges?
-
1
votes1
answer898
viewsPython sockets disconnect client
I would like to make with a command of the server, was disconnected a client specific. from socket import * meuHost = '' minhaPort = 50007 sockobj = socket(AF_INET, SOCK_STREAM)…
-
1
votes2
answers303
viewsIncorrect python value conversion
I have a Rawler who takes the amount STRING R$ 560,000,00. I need to convert this value to FLOAT because I will use this value to carry out consultations, of this type: Selecionar todos os carros…
-
1
votes1
answer2037
viewsSockets - Tic-tac-toe / Rooster Game MULTIPLAYER
EDITED POST I’m creating the so-called 'Tic-tac-toe' (or 'Rooster Game'), right now I’m trying to create a feature that allows two players on different devices - although on the same network - to…
-
1
votes1
answer59
viewsWhy is this server crashing?
from socket import* Host = "localhost" Port = 255 sockobj = socket(AF_INET, SOCK_STREAM) sockobj.bind((Host, Port)) sockobj.listen(5) while True: conexão, endereço = sockobj.accept() print('Server…
-
1
votes2
answers2421
viewsPython problem in sublime text
Well, guys, I’m having a problem when I put my python code in sublime text to run. The problem is, the code doesn’t work, just compile and nothing else. In case, it is not running any line (trying…
-
1
votes1
answer5595
viewsWhat is the best way to perform a menu with submenus ( while with breaks or calling the menus in functions )?
For a school project I need to have a menu with several submenus. What is the best way to approach this? I can put the menus inside whiles and give away break to those whiles when you want to go…
-
1
votes1
answer193
viewsPython Using . replace() with list comprehension
Can someone tell me if I can make it work: a = ['<a1>', '<a2>', '<a3>', '', '<a5>'] b = ['<b1>', '<b2>', '<b3>', '', '<b5>'] txt = '<a1> test…
-
1
votes1
answer38
viewsThis program on Tkinter does not display its widgets. Can anyone explain why?
from tkinter import * class Autenticar(object): def __init__(self, toplevel): self.Lab1 = Label(main, text = "Usuário", fg = "Blue") …
-
1
votes1
answer247
viewsImport error when sending simple email with python
I am learning to send email in python and I am facing several problems. One of them is already in the import of the smtplib module. My code is this: from smtplib import SMTP…
-
1
votes1
answer160
viewsWhat’s wrong with Twitter messaging?
import urllib.request import time def send_to_twitter(msg): password_manager = urllib.request.HTTPPasswordMgr() password_manager.add_password("Twitter…
-
1
votes1
answer79
viewsHow to modify a list in the global Scope using a function? Python 3
def lsum(x): res = [] for i in x: res.append(x+1) L = res L = [1,2,4] lsum(L) print(L) How can I modify the above code without using global L to print("L") "return" [2,3,5]? That is, I want to…
-
1
votes1
answer529
viewsAccess Denied when entering value in windows registry by Python
In an attempt to create a function that inserted a value in a windows registry key, I came across an error. I use Windows 8 and Python 3.5. The function is as follows: def inserir1(nome,path):…
-
1
votes1
answer1862
viewsWhat’s wrong with this python code?
import urllib.request import time def send_to_twitter(): import sys import tweepy CONSUMER_KEY = '1wrnsF5lB8fEWVzRdvlIqdTl' CONSUMER_SECRET = 'eTiylDUHLJgGnTCcxzzCtzHXG4OlHrbY6wLvuZUnAEhrokyNA'…
-
1
votes0
answers70
viewsRun python file(by terminal) by Sublime Text 3
I currently use Atom to write my programs in Python. However, I want to migrate to sublime text for convenience and for being a lighter program. I use a plugin in Atom called: Atom-python-run. He…
python python-3.x sublime-text sublime-text-3asked 7 years, 9 months ago Vinicius Barbosa de Medeiros 331 -
1
votes1
answer363
viewsHow to save a hash to a file?
Code: h = {} arquivo = open("Tabela nome-idade.txt") r = True while r: nome = str(input("Nome: ")) if nome == '': r = False print(h) break idade = str(input("Idade: ")) h[nome] = idade My question…
-
1
votes1
answer693
viewsHow to allow only a range of numbers?
I’m making a student grade number registration code, so I want the user to put a number between a range of 1 to 10, BUT I also want the breaks to be in float(ou seja: 0.1,0.2... 9.8,9.9,10.0).…
-
1
votes1
answer385
viewsPython: problem with list
Would anyone know how to explain and correct why the problem occurs in the exit below when I use repeated numbers? Thank you! The return must be presented in the reverse form and without the "0"…
-
1
votes2
answers3871
viewsMatrix multiplication
Could you help with Matrix in python?! The exercise is as follows, a function matriz_mult(n1, n2) takes two matrices as parameter and returns True if the matrices are multiplied in the given order…
-
1
votes1
answer1560
viewsHow to make a python script run two processes simultaneously?
A little while ago I learned to capture videos via webcam using Python with the Opencv library. After that, I had the idea of making a script that automatically starts and ends the recording of a…
-
1
votes3
answers11849
viewsRestart application in Python
How to restart my program with Python? cpf = input('Digite os nove primeiros dígitos do CPF: ') if len(cpf) != 9: # Aqui deve reniciar a aplicação.
-
1
votes1
answer518
viewsCompare dates in an array?
In the date variable, you are receiving several dates in string as array, want to bring the smallest cont = 0 menor_data = datetime.strptime('31/12/2300', '%d/%m/%Y') while cont < len(datas):…
-
1
votes1
answer1629
viewsPutting password in a python file
I’m making a program in which you select the file you want to lock using a password by clicking on a button that file is locked with a user-defined password. How can I make this file only be…
-
1
votes1
answer2516
viewsCode that calculates days between two dates without using the datetime module
I’m making a code that calculates the days between two dates, but it cannot use the datetime module, and it only gives error. Here’s the code: usuariodata=input() usuariodata2=input()…
-
1
votes2
answers153
viewsPrint the minimum number on the list?
I have this code and I can’t get the number -1 to be shown. It gives an error: not supported between instances of 'str' and 'int'. From what I’ve seen on other forums it has to do with comparing…
python-3.xasked 7 years, 6 months ago Nuno Oliveira 25 -
1
votes1
answer788
viewsHow to collect text when there is no HTML reference class - Crawler Python
I have the following situation below: I want to collect "Text to Crawler" that is below, as I will navigate there without class or id? <td>Texto para crawler</td>…
-
1
votes2
answers712
viewsRename application in Django Admin
Good evening guys, I’m trying to rename the application in Django admin according to the documentation, but it ended up not happening, I think I’m doing something wrong, the code is as follows:…
-
1
votes1
answer753
viewsHow to create a pause method and one that resumes a Thread?
The following script shows the x variable every 3 seconds, while the xx class, which is running on a thread, increases the x value every second. I would like when the value of x reaches 13, the…
-
1
votes0
answers667
viewsProblem making python script request administrator permission
Use Python 3.5 on Windows 8 and a simple script presented problem: I want to copy a file from my desktop to C: Windows folder. First I tried that: from shutil import copy…
-
1
votes1
answer128
viewsI wanted to improve the performance of my program
Good Afternoon, I am currently creating an interface, for an application, but I have a problem, with the function I created. def contornos(self): self.im = cv2.imread(self.imagem) im_copia =…
-
1
votes1
answer238
viewsTypeerror: not all Arguments converted During string formatting
def reduce(self,a,b): self.dividend =a self.divisor = b if(a != 0 and b != 0 ): if(a > b): self.dividend = a self.divisor = b else: self.dividendo = a self.divisor = b while(a % b != 0 ): r = a %…
python-3.xasked 7 years, 6 months ago Lucia 11 -
1
votes1
answer1336
viewsPython data extraction and automatic email sending with information obtained
Friends, The data extraction part is working and the email sending is also in part. I would like the same information that I print on screen and with the same formatting (skipping line etc)) to be…
-
1
votes2
answers4092
viewsHow to convert a list to string and vice versa?
I have a list: ('47075', 'josenestle', 'i need help') I do str1 = str(list) and have it in string. However if you do list(str1) I do not recover my list. I find no obvious solution, help would be…
-
1
votes1
answer449
viewsHow to select and print a value within a list created by a "def"
The title is already self explanatory, as I do to select and choose given str or int float/ inside a list that was created by my record function def registro(cadastroaluno): matricula =…
-
1
votes1
answer1559
viewsHow to print a. txt file in Python
I try to print that part of my work into a file. txt (code below), but I can’t, because at the time of giving Run in the file that whole part comes out blank: It is worth mentioning that even…
-
1
votes1
answer4680
viewsHow to create a form and authenticate Django user
Good night to you all. I am developing a Django project for educational purposes only and I could not find a solution to my problem. I could not generate a form for the user to log in and much less…
python-3.x django login authentication django-templatesasked 7 years, 8 months ago Victor Alessander 387 -
1
votes2
answers1083
viewsSort a. csv file from the numeric column
I have the following file: es;548 la;1832 primera;35 vez;107 que;2598 hago;15 un;878 pedido;642 y;1713 creo;83 ha;207 funcionado;1 muy;371 bien;257 los;1054 precios;88 fuesen;11 And I’d like to sort…
-
1
votes4
answers11441
viewsA list to receive 20 whole numbers and store in a list and print the largest element in the list
n = int(input("digite o número : ") I=0 For i in lista: lista[i].append(input("digite o número" I+=1 else: Print("lista cheia") I’m new to Programming and I can’t implement what the questionnaire…
-
1
votes2
answers1547
viewsAnalyzing strings in a text file and returning the string that appeared most
I need to analyze strings in a text file and return to the one that appears the most (if there is a tie take both) and save in another text file. I open the file and analyze the lines but I do not…
-
1
votes2
answers1783
viewsprint matrix in Phyton
I would like to know how to print a matrix [[2,3], [4,6]] for example, in the form of line below line without using import
python-3.xasked 7 years, 5 months ago mari 11 -
1
votes1
answer979
viewsSending POST with Python via Curl
I want to turn the form (which is working) into a URL to run in the backend <form action="/users/login?ssrc=head&returnurl=https%3a%2f%2fpt.stackoverflow.com%2f" method="post"> <input…
-
1
votes2
answers795
viewsRead files . CAP efficiently with Python
I have some. CAP files originated from catching packages with tcpdump. When trying to open with wireshark, the machine gets very slow, because I imagine he tries to load everything to RAM. I would…
-
1
votes2
answers166
viewshelp with indentation that is generating error in python 3.6
I’m doing a webcrawler I’m having the following problem. I had to do a separate program to print out how many candidates passed each course. Only that the last line is not running, and it would make…
-
1
votes2
answers159
viewsExtracting Window and Time values from a network dump
The following network dump (PCAP format file) is the result of capturing a denial of service attack in the laboratory: I would like to extract the time (Unix time) and the window value (win) and…
-
1
votes1
answer119
viewsHow to make a "time-Slice" in packages in a network dump with Python?
I’m trying to "grab" source Ips and target Ips inside a network dump (PCAP) file. The idea is to save all source Ips and all target IPS by scanning the file every 10 minutes ("time-Slice"), for…
-
1
votes1
answer578
viewsHow to establish a P2P connection?
On a normal connection, it is necessary that whoever will receive the connection is with an open port on the router (transmitting to a computer from the internal network). But in a P2P connection…
-
1
votes3
answers966
viewsHow to store an int and a complete string from within an input?
I wish that at the time of typing in the variable N the word "2 orange juice" the file stores in the variables number and food: number = 2 (preferably integer, but anything I convert it after) food…