flask的views.py里调用自定义方法出现‘AttributeError: 'function' object has no attribute’

fxtest 发布于 2016/11/25 10:46
阅读 1K+
收藏 0

用flask做个网站。在views.py里有代码:

from function import cvdclear
@main.route('/cvdclear',methods=['GET','POST'])
def cvdclear():
	if request.method == 'GET':
		return render_template('cvdclear.html')
	elif request.method == 'POST':
		file = request.files['upfile']
		if file:
			filename = secure_filename(file.filename)
            file.save(os.path.join(app.uploadspath,filename))
			cvdclear.read_xls(filename)
		return render_template('cvdclear.html')



在自定义库function 里有cvdclear.py,代码:
def read_xls(url):
	workbook = xlrd.open_workbook(url)
	table = workbook.sheets()[0]
	title = table.row_values(0)
	nrows = table.nrows
	infovalues = []
	for i in range(1,nrows):
		info = table.row_values(i)
		infovalues.append(info)
	write_xls(infovalues)



在页面上传文件后出现:AttributeError: 'function' object has no attribute 'read_xls'

百思不得其解,求问什么原因?

加载中
0
linshubin
linshubin
cvdclear.read_xls()
返回顶部
顶部