python Excel的操作

算是學習記錄,平常用到的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()








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章