Questions tagged as 'python-3.x'

3
answers

Doubt with Python's str.replace () method

I have the following text:    'box 1 is blue, box 10 is green, box 100 is empty' I want to replace 'box 1' with 'package 2', so I do: >>> texto = 'caixa 1 é azul, caixa 10 está verde, caixa 100 está vazia' >>> print(te...
asked by 30.08.2015 / 19:49
3
answers

How to detect if a variable is null?

I'm trying to validate a simple form in Python 3 and I want to prevent it from registering the information if the nome field is empty, but when I make a if to check that the name variable is empty, it it returns me that it i...
asked by 31.07.2017 / 02:11
3
answers

How to format cpf correctly in python?

I have the following code: test = input ("CPF: ") When the CPF is entered: 12345678900 But when I return this input it returns: 123.456.789-00 How do I do this in Python?     
asked by 14.09.2017 / 18:05
2
answers

Removing duplicate elements in a list with python

I have to do a function and I am not able to develop logic. It is as follows:    Write the remove_repetitions function that receives a list of integers as a parameter, checks to see if such a list has repeated elements, and removes them. The...
asked by 24.03.2017 / 21:48
2
answers

Python Basic Request

How can I make a basic request in Python for a WebServer? I'm trying, but without success. I want to get , in the simplest way anyway.     
asked by 17.10.2016 / 19:32
2
answers

Start a command line tool in Python

How can I create a command line tool in Python that works like ls of Linux or dir of Windows? How would I start a script like the one that will later be compiled as an executable?     
asked by 01.08.2016 / 21:55
4
answers

How to know which version in use of a particular package installed via pip?

I'm starting to program in python and I've been trying to use best practices: virtualenv, pip, etc. One of the packages I have used (pelican) has different help pages for each version. How do I know which version I am using? I installed it with...
asked by 14.06.2015 / 17:21
2
answers

Programming with client and server: How to get numerous data exchanges per client and numerous 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 ao servidor sockobj = socket(AF_INET, SOCK...
asked by 08.04.2018 / 00:54
5
answers

How to find out the type of a variable given by the user?

I would like to ask the user to type something and find out what type of what he wrote. So far I only know input() , but input() only returns String type. If I by int(input()) or float(input()) fall into the sam...
asked by 15.12.2017 / 03:08
1
answer

How do I send a file as an attachment by email without being automatically renamed?

I'm a beginner in sending emails through a script and I'm having a problem. Use Python 3.5. When sending attachments with the following script, they lose the extension and are renamed: def enviaremail(usuario,senha,mensagem,listadestinatarios)...
asked by 17.01.2017 / 20:36