#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/3/20 21:24
# @Author : cunyu
# @Site : cunyu1943.github.io
# @File : LimitedInfo.py
# @Software: PyCharm
import xlrd
import xlwt
file = '网易新闻.xls'
data = xlrd.open_workbook(file)
table = data.sheets()[0]
nrows = table.nrows
ncols = table.ncols
print(nrows, ncols)
workbook = xlwt.Workbook(encoding='utf-8')
news_sheet = workbook.add_sheet('news')
news_sheet.write(0, 0, 'Title')
news_sheet.write(0, 1, 'Content')
data = input('Input the Date,format(2019-03-19:)\n')
rank_list = []
for i in range(1, nrows):
if table.row_values(i)[-1] == data:
print(table.row_values(i)[-1])
print(i)
rank_list.append(i)
print(rank_list)
for i in range(len(rank_list)):
news_sheet.write(i+1, 0, table.row_values(int(rank_list[i]))[0])
news_sheet.write(i+1, 1, table.row_values(int(rank_list[i]))[1])
workbook.save('%s-网易新闻.xls' %(data))
建议关注 公众号,文章会优先发布在此处,此外还有 大量精品资源 等着你。
小编收集资源也很辛苦,大家看完文章后,记得顺手点个在看!或者赞赏个鸡腿儿也是很满足鸭!比心 ♥