import sqlite3#10003[:1]{:2}{2}db = sqlite3.connect(r'c:\imageDB.db')cur=db.cursor();db.commit();try:cur.execute('insert into cet_t values(?,?)',('title2.jpg',sqlite3.Binary('123'),))except sqlite3.IntegrityError:import sysprint sys.exc_info()[0],sys.exc_info()[1]prin Read More
posted @ 2012-11-25 23:38 godjob Views(438) Comments(0) Diggs(0) Edit
# -*- coding: utf-8 -*-"""Created on Sun Nov 25 15:56:01 2012@author: l"""import sqlite3db = sqlite3.connect(r'c:\imageDB.db')#fp=open(r'c:\title.jpg','rb')#data=fp.read();#fp.close()cur=db.cursor()#cur.execute('insert into cet_t values(" Read More
posted @ 2012-11-25 22:30 godjob Views(788) Comments(0) Diggs(0) Edit
import sqlite3def sqlite_basic(): # Connect to db conn = sqlite3.connect('test.db') # create cursor c = conn.cursor() # Create table c.execute(''' create table if not exists stocks (date text, trans text, symbol text, qty real, price real) ... Read More
posted @ 2012-11-25 22:15 godjob Views(1984) Comments(0) Diggs(0) Edit
遍历存元组的列表进行操作一堆xy坐标,找出x,y的左上角与右下角[python] view plaincopyprint?max_t=reduce(lambdax,y:(max(x[0],y[0]),max(x[1],y[1])),l)p;min_t=reduce(lambdax,y:(min(x[0],y[0]),min(x[1],y[1])),l)用zipfile写压缩包[python] view plaincopyprint?f=zipfile.ZipFile("testzip.zip","w",zipfile.ZIP_DEFLATED)f.wri Read More
posted @ 2012-11-25 21:50 godjob Views(288) Comments(0) Diggs(0) Edit
#include <stdio.h>#include <sqlite3.h>#include <stdlib.h>static sqlite3 *db=NULL;static sqlite3_stmt *stmt=NULL;FILE *fp;long filesize=0;char *fflie;int main(int argc, char *argv[]){ int rc,i,j; rc = sqlite3_open("dishes.db", &db); rc = sqlite3_prepare(db, "updat Read More
posted @ 2012-11-25 20:58 godjob Views(1277) Comments(0) Diggs(0) Edit
python中对文件、文件夹的操作需要涉及到os模块和shutil模块。创建文件:1) os.mknod("test.txt") 创建空文件2)open("test.txt",w)直接打开一个文件,如果文件不存在则创建文件创建目录:os.mkdir("file")创建目录复制文件:shutil.copyfile("oldfile","newfile")oldfile和newfile都只能是文件shutil.copy("oldfile","newfile") Read More
posted @ 2012-11-25 00:16 godjob Views(299) Comments(0) Diggs(0) Edit