运行环境python3.6
import xlrd
from flask import Flask, requestapp = Flask(__name__)@app.route("/", methods=['POST', 'GET'])
def filelist1():print(request.files)file = request.files['file']print('file', type(file), file)print(file.filename) # 打印文件名f = file.read() #文件内容data = xlrd.open_workbook(file_contents=f)table = data.sheets()[0]names = data.sheet_names() # 返回book中所有工作表的名字status = data.sheet_loaded(names[0]) # 检查sheet1是否导入完毕print(status)nrows = table.nrows # 获取该sheet中的有效行数ncols = table.ncols # 获取该sheet中的有效列数print(nrows)print(ncols)s = table.col_values(0) # 第1列数据for i in s:ii = i.strip()print(len(ii))return 'OK'if __name__ == '__main__':app.run(host='0.0.0.0', port=7000)