19
20
21
# 需安装 xlrd-0.9.2 和 xlutils-1.7.1 这两个模块
from xlwt import Workbook, Formula
import xlrd
book = Workbook()
sheet1 = book.add_sheet('Sheet 1')
sheet1.write(0,0,10)
sheet1.write(0,1,20)
sheet1.write(1,0,Formula('A1/B1'))
sheet2 = book.add_sheet('Sheet 2')
row = sheet2.row(0)
row.write(0,Formula('sum(1,2,3)'))
row.write(1,Formula('SuM(123)'))
row.write(2,Formula("$A$1+$B$1*SUM('ShEEt 1'!$A$1:$b$2)"))
book.save('formula.xls')
book = xlrd.open_workbook('formula.xls')
sheet = book.sheets()[0]
nrows=sheet.nrows
ncols=sheet.ncols
for i in range(nrows):
for j in range(ncols):
print (sheet.cell(i,j).value)
python3.2 ==>ORM(或者数据库接口) ==>数据库数据库:PostgreSQL9、SQLite3等ORM:SQLAlchemy(需要安装数据库接口)数据库接口:psycopg2(PostgreSQL9)建议使用ORM样创建、修改、删除时只涉及python类对象无需写sql语句修改了数据表结构时对程序修改也方便些表间关系特别复杂也ORM直接写sql语句代码部分:
from django.db import models
class Student(models.Model):
name = models.CharField(max_length=30)
grade = models.IntegerField()
执行部分 :
python manage.py makemigrations
python manage.py migrate
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)