July 31, 2012CHENTONG Reading time ~1 minute Python 经典小程序 字典生成 #--a file--------- chr1 1 chr2 2 #------end file---- dict([line.strip().split() for line in open(file)]) Global variable First global variable_name when using global variable in a function python判断是否到文件结束 if line: # not end print 'Non-end' if line.strip(): # not blank line print "Non-blank" Python start local server #Will run an instant file server on port 8000 on the current directory python -m SimpleHTTPServer -