check type
1
isinstance(n,int)
list
1
2
3
4
5
6
7
8t1 = ['a', 'b', 'c'];
t2 = ['d', 'e', 'f'];
t1.extend(t2);
t1.append('g');
t1 = t1+['g']
t1.sort();
del t1[1:3];
t1.remove('b');dictionary
1
2
3
4
5
6
7eng2sp = {'one': 'uno', 'two': 'dos', 'three': 'tres'}
eng2sp.values() #'uno','dos','tres'
eng2sp.items()
'one' in eng2sp #true
inverse = invert_dict(eng2sp)
d = dict(zip('abc',range(3)))
d.get(word,0) #d[word] if word in d, 0 otherwisetupe: similar with list but immutable
file operation
1
2
3
4
5
6
7
8fout = os.getcwd()
os.path.abspath('tmp.txt')
os.path.exists('tmp.txt')
os.path.isfile/isdir
os.listdir(cwd)
fout = open('output.txt','w')
fout.write('hehe')
fout.close()