打开cmd
pip install xlrd
#或者去pycharm中下也可以
# 打开实验数据表格
book = xlrd.open_workbook('../景区信息.xlsx')
# 选择页数为第1页
sheet1 = book.sheets()[0]
# 数据总行数
nrows = sheet1.nrows
# 数据总列数
ncols = sheet1.ncols
# 获取表中第三行的数据
x = sheet1.row_values(2)
# 获取表中第二列的数据
y = sheet1.col_values(1)
#获取第五列中的第二个数据
z = sheet1.col_values(4)[1]
# 获取表中第二列且不要第一个值的数据
y_noone = sheet1.col_values(1)[1:]
# [1:]相当于切片操作
x_3_y_3 = sheet1.cell(2, 2).value
# 当然也可以修改
pip install openpyxl
wb = Workbook()
ws = wb.create_sheet('111')
ws.append(['发布时间','文本内容','转发数量','评论数量','赞数量','收藏数量'])
ws2 = wb.active
ws2.title
book = openpyxl.load_workbook('../景区信息.xlsx')
sheet1 = book['Sheet1']
len_row = sheet1.max_row
len_column = sheet1.max_column
location = sheet1.cell(5, 5).value
sheet1.cell(num, 6).value = 5
sheet1.cell(num, 7).value = 6
book.save(filename="../景区信息.xlsx")
book.close()