python中可变长度参数列表_Python:具有可变长度参数列表的函数

我试图从Excel表格中绘制一些数据(在同一个图上),我想要一个可变长度的字符串列表作为输入,对应不同的材料。我得到以下错误:

TypeError:“NoneType”对象不可读取

我真的不明白为什么。代码如下: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

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页