xqn2017

导航

python Excel的操作

import xlrd
import matplotlib.pyplot as plt
if __name__ == '__main__':
    target = xlrd.open_workbook('first.xls','r')  #文件名要写完整路径,这里的文件直接放在了和.py同一个目录了
    sh = target.sheet_by_index(0) #取第一张表  
    col0Values = sh.col_values(0) # 取第一列
    col1Values = sh.col_values(1)  # 取第二列
    plt.plot(col0Values,col1Values)
    plt.show()

  

posted on 2017-12-08 19:13  xqn2017  阅读(254)  评论(0编辑  收藏  举报