python文件命名時的注意點


   在python中讀取Excal文件,需要引用xlrd模塊,因此建的這個python文件名為xlrd.py

部分代碼如下:

import xlrd

import os

newpath = os.chdir(r'Excal文件所在路徑')

filename = ‘Excal文件名’

file = os.join(os.getcwd(),filename)

 

xl = xlrd.open_workbook(file)  #打開文件

table1 = xl.sheet_by_name('某一sheet頁的名字')  #獲取sheet頁內的匯總數據

print table1.cell_value(0,0)  #獲取第0行第0列的值

執行程序報"AttributeError: module 'xlrd' has no attribute 'open_workbook'",把python文件名xlrd1.py改為xlrd.py解決此問題


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM