1 # coding=utf-8-sig 2 3 4 #获取操作文件路径 5 import os,sys 6 file_folder = sys.argv[1] 7 8 #文件生成到桌面 9 import sys,os 10 desktop_path = os.path.join(os.path.expanduser('~'),"Desktop/") 11 12 #时间格式 13 import datetime 14 TIME2 = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") 15 16 # 生成一组随机数字 17 import random 18 y = [random.randint(20,35) for i in range(120)] 19 20 # 生成一组伪随机数字 21 import numpy as np 22 np.random.seed(10) 23 t = np.random.randint(0,20,(3,4)) 24 print(t) 25 26 #设置字体 中文显示 27 from matplotlib import pyplot as plt 28 from matplotlib import font_manager 29 my_font = font_manager.FontProperties(fname="/System/Library/Fonts/Hiragino Sans GB.ttc") 30 plt.title("饼图示例-8月份支出",fontproperties=my_font) 31 32 # numpy 多维转为一维 33 import numpy as np 34 t1 = np.array([[[1,2,3],[4,5,6]],[[7,8,9],[10,11,12]]]) 35 t2 = t1.flaten() 36 print(t2.share)