print r"output message\n\r"
print ord('A')
print chr(65)
print u'中文'
print "%s have $%d" % ("you", 100)
list, tuple, dict, set
def nop():
pass
if not isinstance(x, (int, float)):
raise TypeError('bad operand type')
L 是一个list或者tuple
L[1:3], L[-2:], L[:]
[x * x for x in range(1, 11) if x % 2 == 0]
>>> def odd():
... print 'step 1'
... yield 1
... print 'step 2'
... yield 3
... print 'step 3'
... yield 5
>>> o = odd()
>>> o.next()
step 1
1
>>> o.next()
step 2
3
>>> o.next()
step 3
5
import functools
int2 = functools.partial(int, base=2)
def read_file(path):
s = set([])
f = open(path, 'r')
for line in f.readlines():
s.add(line.strip())
return s
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/mpl-data/fonts/ttf
http://blog.csdn.net/y12345678904/article/details/72757912
查看 matplotlib 所在目录:print(matplotlib.matplotlib_fname()) 其他:http://www.jianshu.com/p/02956fb520a7