基本库
-
判断字符串为空
s=' ' if s.strip()=='': print 's is null' # 或者 if not s.strip(): print 's is null'
-
plt
# 显示图像 plt.show() # 暂停 plt.pause(10) # second # 关闭图像 plt.close()
-
json文件保存与读取
model={} #数据 with open("./hmm.json",'w',encoding='utf-8') as json_file: json.dump(model,json_file,ensure_ascii=False)
model={} #存放读取的数据 with open("./hmm.json",'r',encoding='utf-8') as json_file: model=json.load(json_file)
解决读取出来数据为unicode的问题方法:
def byteify(input, encoding='utf-8'): if isinstance(input, dict): return {byteify(key): byteify(value) for key, value in input.iteritems()} elif isinstance(input, list): return [byteify(element) for element in