Questions tagged as 'python'

2
answers

Building a web crawler in python. I need help adding threads

I'm trying to develop a web crawler for studies. He is very simple and would like to improve it. How to use threads to speed up / improve the process? The program could make several links in parallel. How to apply the thread concept to the crawl...
asked by 01.08.2016 / 02:28
2
answers

How to format dates in python?

When I do this: data = input('data [d/m/Y]: ') print(data) data2 = datetime.strptime(data, "%d/%m/%Y") print(data2) It returns me like this: data [d/m/Y]: 17/08/2018 17/08/2018 2018-08-17 00:00:00 How do I format the da...
asked by 18.09.2018 / 20:08
1
answer

How to sum values from a csv using Python?

I have a csv file similar to this one, with all the information of all municipalities in Brazil (I shortened the csv to not be too long): ESTADO,MUNICIPIO,HABITANTES,AREA AC,ACRELÂNDIA,12538,1807.92 AC,ASSIS BRASIL,6072,4974.18 AC,BRASILÉIA,21...
asked by 03.10.2018 / 23:43
2
answers

How to store an operator?

I'd like to know if you have any way to save an operator to a variable, for example a = < if 5 a 5: pass     
asked by 12.02.2018 / 02:29
3
answers

What is the logic behind this function?

Why the result of L1 is: [2, 3, 4] instead of [3, 4]? def remove_dups(L1, L2): for e in L1: if e in L2: L1.remove(e) L1 = [1, 2, 3, 4] L2 = [1, 2, 5, 6] remove_dups(L1, L2) print(L1) I tested it in Python Tut...
asked by 02.04.2018 / 16:53
2
answers

Count certain characters in a word in python

I'm making a command to help you read a globe. entrada = int(input("Quantos centimetros no globo: ")) km = entrada * 425 m = km * 1000 cm = m * 100 print(entrada, "centimetros no globo equivalem a:", km, "quilometros", m, "metros e", cm, "cen...
asked by 15.12.2017 / 19:37
1
answer

Function that adds values to the list

I have a problem and need to create a function that adds values that are within a list. I have done this and the code is down, however, Python returns me the value 3 as a result, when in fact the value should be 103. I can not find the error at...
asked by 07.11.2017 / 00:13
2
answers

List of objects in Python

I'm doing a function that returns an object list. Code snippet: def guarda_word(lista_palavras,lista_objeto,indice): for i in lista_palavras: if bool(lista_objeto) == True: # a list de objeto esta vazia i = PalavraIndi...
asked by 07.10.2017 / 20:34
2
answers

How to do string interpolation in Python?

For example, in PHP we can do this: $preco = 200; $unidades = 10; $texto_final = "O produto custa {$preco} reais e restam {$unidades} unidades."; Is it possible to do something similar in Python or do I need to concatenate always?     
asked by 22.12.2017 / 07:10
2
answers

What is the equivalent of 'explode' from PHP in Python?

In PHP, if I want to split a multi-part string based on a delimiter, I use explode . How can I do the same in Python?     
asked by 15.06.2018 / 05:33