Skip to content

Instantly share code, notes, and snippets.

@jiankuang
Last active March 17, 2017 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jiankuang/70a63513bfa16c74b4135ecfcc54af6c to your computer and use it in GitHub Desktop.
Save jiankuang/70a63513bfa16c74b4135ecfcc54af6c to your computer and use it in GitHub Desktop.
Python snippets
>>> tax = 12.5 / 100
>>> price = 100.50
>>> price * tax
12.5625
>>> price + _
113.0625
>>> round(_, 2)
113.06

split Function

>>> str = "Hello,world,how,are,you"
>>> str.split(",")
['Hello', 'world', 'how', 'are', 'you']
>>> str.split(",")[0]
'Hello'
>>> str.split(",")[1]
'world'
>>> str.split(",", 1)
['Hello', 'world,how,are,you']
>>> str.split(",", 2)
['Hello', 'world', 'how,are,you']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment