Questions tagged as 'python'

1
answer

How do I know which source I'm running Python?

I'd like to know how do I know which source I'm running the Python from. For example, if I installed Python 3.5 on my machine and created a Virtualenv, how could I know from Python itself the source of execution of that binary? For...
asked by 23.07.2018 / 19:47
1
answer

What would be the equivalent of find for lists in python?

What would be equivalent to find used in strings to use in lists? For example, if it is a=['a','b','c'] , how do I return to position 1 of 'b' ?     
asked by 12.07.2018 / 13:23
1
answer

How does any and all work in Python?

How do the any and all functions work in Python and what are the differences between them? Are these functions equivalent to Array.prototype.some and Array.prototype.every of Javascript?     
asked by 29.03.2017 / 17:05
2
answers

How to count occurrences of a substring in a string in Python?

How do I read two strings and check the number of occurrences of the second string in the first? Example: If the first string entered is "abracadabra" and the second "bra" , then the number of occurrences will be 2 .     
asked by 17.04.2017 / 04:33
1
answer

Python indentation error

I'm new to Python and I'm doing a project ... however I've run this and gave an error on line 44, whose message is:    IndentationError: expected an indented block import blockchain, threading, requests coins_API = ["https://www.merca...
asked by 18.10.2017 / 04:17
2
answers

Checking a DoS / DDoS (Denial of Service) attack on a network dump (PCAP file)

from scapy.all import * import dpkt f1 = open("semAtaque.pcap") pcap = dpkt.pcap.Reader(f1) f1.close() f2 = open("Ataques.pcap") pcap = dpkt.pcap.Reader(f2) f2.close() I have two network traffic captures for a lab experiment: one free of att...
asked by 10.03.2017 / 18:51
2
answers

Convert string to list?

I needed to pass%% of type: 0.4350 0.8798 0.0099 1 for a string [0.4350, 0.8798, 0.0099, 1] with a simple list . How can I do this?     
asked by 01.05.2017 / 16:46
1
answer

Methods __str__ and __unicode__

I have already seen class codes that implement Django models overriding both __str__ and __unicode__ , is there any difference between them? If so, is there a case that I should prefer one instead of another?     
asked by 25.05.2017 / 17:31
2
answers

What is the numeric type builtins?

I read in the book Python for Developers: Approach Python 3.3 the following excerpt:    In addition to the numeric builtins type of the interpreter, in the library   Python standard there are several modules dedicated to implementing othe...
asked by 19.05.2017 / 16:33
2
answers

How to save a graphic in a PNG image?

I have some data from an experiment, and would like to save them as PNG. To display the data, I simply do show() . However, I would like to save directly as PNG to not get print out of the screen. How do I display my data: import matp...
asked by 12.12.2018 / 13:40