Questions tagged as 'python'

1
answer

Remove whitespaces from the list in Python

I'm reading a file, stopwords.txt , and in this file each stopword is in a line, a o para Each stopword I am saving in a list as follows: with open(sys.argv[1],"r") as file_entrada: lista_nome_base_docs = [line.rstrip() for l...
asked by 05.10.2017 / 15:09
3
answers

Number of numbers greater than 7 in a list in Python

I want to know how many numbers are greater than 7 in the 'a' list.    Note: I'm using slicing because in the case I'm putting in   practice, I do not know how many items you have on the list. a=[5, 10, 6, 8] qmaior= a.count([:-1])>7...
asked by 05.11.2017 / 04:21
1
answer

How to resize graphics in IPython Notebook without loss of quality?

In IPython Notebook I produce graphics with (for example): x = [1,2,3,4] y = [5,6,7,8] plot(x, y) When I position the cursor on the generated graph, the tool to resize the graph appears in the lower right corner, but when I resize it it bec...
asked by 14.12.2013 / 22:49
1
answer

Python - QDate to datetime conversion

I need to convert a date input by a QCalendar to datetime (from the datetime lib). How can I do it?     
asked by 24.07.2017 / 19:39
2
answers

How to set Python 3 as default in linux?

When I type the command python , Ubuntu runs Python 2.7. But in the new versions of Ubuntu, Python 3 is also usually installed. When I run python -V , "Python 2.7.12" appears, but I would like to use the python command to ru...
asked by 29.06.2018 / 14:31
2
answers

python - Delete characters from the end of a string

Is there any way to delete characters at the end of a string in python? For example:     a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"     B="ABCDEFGH" I need the string "a" to be the same size as "b", is it possible? I need them the same size to do a cr...
asked by 15.04.2017 / 15:39
1
answer

How do I get the final URL of a JS redirect?

I was trying to make a code to get the final redirect url of some links, I could do for most of the links I needed, so I could not: link All other links worked with urllib2 or requests. s = requests.Session() r = s.get(lili[i], he...
asked by 23.04.2017 / 17:10
1
answer

Calculation of the Shannon entropy in a network traffic (saved in CAP file) using Python

I have a dump file (CAP format) of a network traffic capture made with the Ubuntu tcp dump. Until a certain time, it is attack-free traffic. Then a series of TCP SYN flooding attacks begin. My goal is to calculate the entropy of each of the traf...
asked by 01.03.2017 / 15:17
2
answers

Displaying certain vectors in a 2D Python list

I have the following situation: - I have a variable called (distrow_vector). This variable receives a 2D list with multiple vectors. - I want it to be displayed, only vectors whose sum of their indexes are less than 100. - I have the code below,...
asked by 26.02.2017 / 19:43
1
answer

preApproval data is required

Currently, I am trying to integrate a prepayment via v2 from api to pagseguro. For some reason I keep getting pre-approval data is required. I tried chaning the headers, I was also checking the example in the documentation and did not seem to be...
asked by 17.02.2017 / 02:12