画图
import matplotlib.pyplot as plt
plt.figure(1)
# plt.subplot(211)
plt.plot(x, y[begin:end], 'r')
plt.xlabel('Hot words')
plt.ylabel('Visit times')
plt.show()
"{1} {0} {1}".format("hello", "world") # 设置指定位置
'world hello world'
命令行参数解析optparse
import logging
from optparse import OptionParser
# Display progress logs on stdout
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
# parse commandline arguments
op = OptionParser()
op.add_option("--lsa",
dest="n_components", type="int",
help="Preprocess documents with latent semantic analysis.")
op.add_option("--no-minibatch",
action="store_false", dest="minibatch", default=True,
help="Use ordinary k-means algorithm (in batch mode).")
日志和时间
随机数
from random import randint