Excel シートのデータを (同じ図に) プロットしようとしていますが、さまざまな材料に対応する文字列の可変長リストを入力として使用したいと考えています。次のエラーが表示されます: TypeError: 'NoneType' object is not iterable 理由がよくわかりません。コードは次のとおりです。
import xlrd
import matplotlib.pyplot as plt
from numpy import *
def transmittance(*glass):
wb=xlrd.open_workbook('schott_optical_glass_catalogue_excel_december_2012.xls')
sheet1=wb.sheet_by_index(0)
transm_index=[] #lista vuota
plt.figure(1)
plt.xlabel('wavelength $\lambda$[nm]')
plt.ylabel('transmittance')
for item in glass:
for i in range(sheet1.nrows):
if sheet1.cell_value(i,0)==glass:
reversed_transmission=sheet1.row_values(i,37,67)
transm_index=reversed_transmission[::-1]
new_transm_index=[float(ni) for ni in transm_index ]
wavel_range=sheet1.row_values(3,37,67)
temp_wavel= [k.split('/')[1] for k in wavel_range]
wRange=map(int,temp_wavel[::-1])
plt.plot(wRange,new_transm_index, 'r-')
plt.grid(True, which="both")
plt.show()
return new_transm_index, wRange
if __name__=='__main__':
new_transm_index=transmittance('N-BASF64','N-BK7')
print 'get tuple length and glass name: ' ,new_transm_index