Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Python sqlite3ºÍµ¥Ôª²âÊÔ

 
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
try:
os.remove(get_db_path())
except:
pass
self.con1 = sqlite.connect(get_db_path(), timeout=0.1) # Á¬½ÓÊý¾Ý¿â
self.cur1 = self.con1.cursor() # »ñÈ¡Óαê
self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
self.cur2 = self.con2.cursor()
def tearDown(self): # µ¥Ôª²âÊÔ»·¾³Çå³ý
self.cur1.close() # ¹Ø±ÕÓαê
self.con1.close() # ¹Ø±ÕÁ¬½Ó
self.cur2.close()
self.con2.close()
os.unlink(get_db_path())
def CheckDMLdoesAutoCommitBefore(self):
self.cur1.execute("create table test(i)") # Ö´ÐÐSQL²éѯ
self.cur1.execute("insert into test(i) values (5)")
self.cur1.execute("create table test2(j)")
self.cur2.execute("select i from test")
res = self.cur2.fetchall()
self.failUnlessEqual(len(res), 1) # ²âÊÔ
def CheckInsertStartsTransaction(self):
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
self.cur2.execute("select i from test")
res = self.cur2.fetchall()
self.failUnlessEqual(len(res), 0)
def CheckUpdateStartsTransaction(self):
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
self.con1.commit()
self.cur1.execute("update test set i=6")
self.cur2.execute("select i from test")
res = self.cur2.fetchone()[0]
self.failUnlessEqual(res, 5)
def CheckDeleteStartsTransaction(self):
self.cur1.exec


Ïà¹ØÎĵµ£º

Python PAMIEʾÀý

 ×ª×Ô:http://blog.chinaunix.net/u3/103146/showart_2058891.html
PythonÕâÖֽű¾ÓïÑÔµÄÇ¿´ó¹¦ÄÜÔ½À´Ô½±»¹ã´óµÄ³ÌÐòÔ±ËùÖØÊÓ£¬ÕâÖÖ֮ǰÔÚ¹úÄÚÁ÷ÐжȲ»¸ßµÄÓïÑÔ½üÀ´ÆøÊƸßÕÇ¡£¸÷ÖÖµÚÈý·½Ä£¿é²ã³ö²»Çî¡£
 
±¾ÎĽéÉܵıãÊÇÒ»ÖÖÄܷdz£·½±ã²Ù×÷IEµÄµÚÈý·½¹¤¾ß£¬PAMIE£¬ËûÄÜÈÃÄãÈçͬдJSÒ»ÑùÀ´²Ù×÷IEä¯ÀÀÆ÷¡£°üÀ¨×Ô ......

[_Êý¾ÝÍÚ¾ò_] pythonʵ¼ùÖ®1

 ¼Æ»®Õâ¸öÐÇÆÚѧϰÓÃpythonʵÏÖ¾ö²ßÊ÷Ëã·¨¡£½ñÍí¾ÍÅöµ½Á˺öàÎÊÌ⣬ºÃ¾ÃûÓÐÓÃpythonÁË£¬²¢ÇÒ3.0ºÍÊé±¾ÉϵÄÓÐЩ¶«Î÷²»Ì«Ò»Ö£¬ÕâÀï¼Ç¼Ï¼¸¸öµØ·½¡£
1£© import module Èç¹û²»ÊÇÔÚ±ê׼Ŀ¼Ï£¨ÏµÍ³µÄpath£¬pythonµÄĿ¼£¬µ±Ç°Ä¿Â¼£©£¬ÄÇôÐèÒªÏÈimport sys£¬È»ºósys.path.append('')£»
2£© ¸Ä±äÔ´Îļþºó£¬ÔÙ´Îimport ......

Python¿ª·¢Activex×é¼þ

PythonÇ¿µÄ¹¦ÄܾÍÔÚÓÚËüÎÞËù²»ÄÜ¡£
ʹÓÃwin32comÄ£¿é¿ª·¢window ActiveXµÄʾÀý£º£¨Èç¹ûÄ㻹ûÓÐ×°win32comÄ£¿éµÄ»°£¬Çëµ½http://python.net/crew/skippy/win32/Downloads.htmlÏÂÔØ£©¡£
# SimpleCOMServer.py
class PythonUtilities:
_public_methods_ = ['SplitString']
_reg_progid_ = "Python.Utilities"
......

ʹÓÃPythonÓïÑÔÉè¼Æ»ùÓÚHTMLµÄCÓïÑÔÓï·¨¼ÓÁÁÏÔʾ³ÌÐò

2005-2006ѧÄêµÚ1ѧÆÚ
±à Òë Ô­ Àí 
¿Î ³Ì Éè ¼Æ ±¨ ¸æ
°à¼¶   02¼Æ(¶þ)   
ѧºÅ     19     
ÐÕÃû     ÁõÏþÃ÷     
³É¼¨           
Ö¸µ¼½Ìʦ   ¬³¯»Ô   
Ò»¡¢   Éè¼ÆÄ¿µÄ
¼ÓÉî¶Ô±àÒ ......

PythonǶÈëC++

PythonǶÈëC++Ïê½â(1)--HelloWorld
À´CSDNµÄʱºò£¬¸Õ¸Õ½Ó´¥Python£¬ÄÇʱºò¶ÔPythonµÄǶÈ벿·ÖºÜ¸ÐÐËȤ£¬Ö»ÊÇһֱûÓÐʱ¼äÀ´ÅªÇåÆäÃæÉ´£¬Òò´ËҲһֱûÓÐʹÓÃǶÈëµÄ¹¦ÄÜ£¬ÁíÒ»¸öÔ­ÒòÊÇÎÒ»¹Ã»ÓÐÕæÕýÓÃPythonд¹ýÒ»¸öÕýʽµÄÓÐÓõãµÄ¶«Î÷£¬²»¹ý£¬ÏÖÔڻعýÍ·À´¼ÌÐø¿´ÕâÒ»²¿·Ö£¬·¢ÏÖ»¹ÊÇͦ¼òµ¥µÄ¡£ÒÔǰÏë°ÑÕⲿ·Ö·­Òë³öÀ´£¬¿ÉÊÇÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ