#encoding:utf-8
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# -*- coding=utf-8 -*-
#Using GPL v2
#Author: ihipop@gmail.com
#2010-10-27 22:07
import xlrd 
import xlwt
from xlutils.copy import copy 
import os
import re
from datetime import datetime
#from __future__ import division
 
import sys,time
Money = 0
Size = 0
print("预算:")
Money = int(input())
print("面积:")
Size = int(input())
data_e = xlrd.open_workbook('11号楼价格表.xls')	    
table_e = data_e.sheet_by_index(0)
nrows = table_e.nrows  		
ncols = table_e.ncols
print("房间号(面积):")
num = 0
for j in range(5,nrows,1):
	if ((int(table_e.cell(j,2).value))>=Size and (int(table_e.cell(j,5).value))< Money):	
		for i in range(1,ncols,1):
			if i == 1:
				if num == 5:
					print("\n")
					num = 0
				print(str(table_e.cell(j,i).value) + " " + str(table_e.cell(j,i+1).value),end= '   ')
				num = num + 1
print("\n")				
for j in range(5,nrows,1):
	if ((int(table_e.cell(j,2).value))>=Size and (int(table_e.cell(j,5).value))< Money):
		print("-------------------------------------------------")
		for i in range(1,ncols,1):
			if i == 5:
				print("首付:"+str(int(table_e.cell(j,i).value)))
			elif i == 1:
				print("房间号:"+str(table_e.cell(j,i).value))
			else:
				print(table_e.cell(j,i).value,end='     ')			

注意:data_e = xlrd.open_workbook('11号楼价格表.xls')     open打开表格的格式,必须是.xls.

思路:遍历每一行,用预算筛选出序号,再打印出改序号对应的楼层、面积等信息。     

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐