Questions tagged as 'python'

1
answer

Transform list of strings into list of tuples

I have this: l=['Car 8', 'Bike 5', 'Train 10'] And I would like to have something like this: [('Car','8'), ('Bike','5'), ('Train','10')] How could you make a list of strings into something like a list of strings tuples?     
asked by 05.12.2017 / 01:27
3
answers

Difficulty with web scraping

<tr bgcolor="FFF8DC"> <td valign="top">25/06/2014 20:37</td> <td valign="top">25/06/2014</td> <td> <a href="Javascript:AbreArquivo('430489');">BROOKFIELD INCORPORAÇÕES S.A.</a>...
asked by 26.06.2014 / 05:37
1
answer

How to install Python 3

I'm new to Ubuntu and I'm learning Python. I have installed Pyhton 2.7.12 on my pc and would like to know how I can upgrade to version 3. I'm doing a course where I need to make use of a lib. import urllib.request But the following er...
asked by 02.09.2016 / 12:44
1
answer

How this expression 'a' = c = 'z' is evaluated in Python

I would like to know the order of evaluation of this expression in Python: if 'a' <= c <= 'z': # c é uma variável de tipo 'chr' print("Ronal... D'oh!")     
asked by 15.10.2014 / 00:48
2
answers

Calculate the divisors of a number in Python in a performatic way

The code I'm using is: import time def divisores(num): for i in range(1, int(num/2+1)): if num % i == 0: yield i yield num inicio = time.time() d = divisores(47587950) [print(i) for i in d] print("Fim da execuçã...
asked by 25.03.2017 / 19:32
1
answer

Regex for python float validation

   r "[+ -]? \ d *.? \ d +" This regex is accepting numbers with more than one point Ex: 12.23.43 and was not to accept ...     
asked by 31.03.2017 / 18:23
1
answer

Graph of total connections per second during a denial of service attack

I have a network dump (PCAP file) containing slowloris attacks: ThefollowingscriptwillshowthenumberofconnectionspersecondtoIP192.168.1.2onport80:tcpdump-qns0-A-r1.pcaphost192.168.91.5andport80|sed-une's/^\(.\{8\}\).*IP\(.*\)\.[0-9]\+>192.168...
asked by 24.05.2017 / 16:25
1
answer

How to convert screen coordinates to Cartesian coordinates?

In Python: How to convert screen coordinates to Cartesian coordinates, where there may be positive and negative points and the center of the screen is (0,0)?     
asked by 18.02.2014 / 17:34
2
answers

What is the native Python support for database manipulation?

I found things about a module called mysqldb, but I did not find documentation available at docs.python.org Please disregard responding with frameworks such as Django.     
asked by 28.06.2017 / 06:29
2
answers

Find lower string of a list in python

How do I make a function to determine the smallest string in a list by ignoring spaces? For example, when typing: menor_elemento(["joão", " a ", "arrozz"]) The output should return "a" (without spaces), because it is the smallest strin...
asked by 10.06.2017 / 17:11