Last active
May 25, 2016 12:02
-
-
Save mbrenig/80e08cab8a8dae05e652a4011fac6703 to your computer and use it in GitHub Desktop.
Python libraries demo
This file contains 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
# https://pypi.python.org/pypi/python-dateutil/2.5.3 | |
# https://dateutil.readthedocs.io/en/stable/ | |
from dateutil import parser # pip install python-dateutil | |
if __name__ == '__main__': | |
try: | |
a = parser.parse("18 Aug 2001") | |
print a | |
b = parser.parse("2016-04-05 12:33:55") | |
print b | |
c = parser.parse("25th May 2016, 1pm") | |
print c | |
except ValueError, e: | |
print "Error parsing date: %s" % e | |
print (b - a).days | |
This file contains 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
def myfunc(a, b): | |
import pdb;pdb.set_trace() | |
return a+b | |
if __name__ == '__main__': | |
print myfunc(1,2) | |
print myfunc(1, "2") | |
# python -m pdb pdbdemo.py |
This file contains 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
# https://pypi.python.org/pypi/pyperclip | |
import pyperclip # pip import pyperclip | |
if __name__ == '__main__': | |
text = "Some long block of text data." | |
pyperclip.copy(text) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment