Created
June 14, 2017 14:44
-
-
Save seedifferently/c11541b734f29ee22d150eb735206c42 to your computer and use it in GitHub Desktop.
Python ip counter dict example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# assuming "ip_counts" is our dict and "req.ip_address" is the requestor's IP address | |
if req.ip_address in ip_counts: | |
# increment the count | |
ip_counts[req.ip_address] += 1 | |
else: | |
# set an initial count | |
ip_counts[req.ip_address] = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment