Python MySqlDB Ôöɾ¸ÄÊý¾Ý¿â
ÏÂÔØ°²×°MySQLdb
http://sourceforge.net/projects/mysql-python/ ºÃÏñû¿´µ½windows°æ±¾for python2.6µÄÏÂÔØ£¬ÍøÉÏËÑË÷µ½Ò»¸ö
http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
°²×°ºóimport MySQLdb»á³öÏÖ DeprecationWarning: the sets module is deprecated ÕâÑùÒ»¸ö¾¯¸æ£¬googleÖ®
ÔÒòÊÇ2.6²»ÖªsetsÕâ¸öÄ£¿é£¬²»¹ýÒѾÌí¼ÓÁËsetÄÚÖú¯Êý¡£ÕÒµ½MySQLdbÎļþ¼ÐµÄÖÐ__init__.py,×¢Ê͵ôfrom sets import ImmutableSet class DBAPISet(ImmutableSet):Ìí¼Óclass DBAPISet(frozenset):£»ÕÒµ½converters.py×¢Ê͵ôfrom sets import BaseSet, Set¡£È»ºóÐ޸ĵÚ45ÐкÍ129ÐÐÖеÄSetΪset¡£
¸ã¶¨¡£
ÏÂÃæ¿ªÊ¼²Ù×÷µÄdemo:
Python´úÂë
# -*- coding: utf-8 -*-
#mysqldb
import time, MySQLdb
#Á¬½Ó
conn=MySQLdb.connect(host="localhost",user="root",passwd="",db="test",charset="utf8")
cursor = conn.cursor()
#дÈë
sql = "insert into user(name,created) values(%s,%s)"
param = ("aaa",int(time.time()))
n = cursor.execute(sql,param)
print n
#¸üÐÂ
sql = "update user set name=%s where id=3"
param = ("bbb")
n = cursor.execute(sql,param)
print n
#²éѯ
n = cursor.execute("select * from user")
for row in cursor.fetchall():
for r in row:
print r
#ɾ³ý
sql = "delete from user where name=%s"
param =("aaa")
n =&nb
Ïà¹ØÎĵµ£º
Python±ê×¼¿â-randomÄ£¿é
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉú³ÉÆ÷. »ù±¾Ëæ»úÊýÉú³ÉÆ÷(»ùÓÚ Wichmann ºÍ Hill , 1982 µÄÊýѧÔËËãÀíÂÛ) ¿ÉÒÔͨ¹ýºÜ¶à·½·¨·ÃÎÊ, Èç Example 2-29 Ëùʾ. 2.17.0.1. Example 2-29. ʹÓà random Ä£¿é»ñµÃËæ»úÊý×Ö File: random-example-1.py import random for i i
¡¡¡¡
random Ä£¿é°üº¬Ðí¶àËæ»úÊýÉ ......
µ÷ÓÃÒ»¸ö¿ØÖÆÌ¨³ÌÐò£¬»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬»ò°ÑËüµÄ±ê×¼Êä³öÖØ¶¨Ïòµ½½çÃæÉÏ£¬ÕâÀïÖ»½éÉÜÈçºÎ»ñÈ¡ËüµÄ±ê×¼Êä³ö£¬ÒòΪÔÀí¶¼Ò»ÑùµÄ¡£
ʹÓÃpython2.5µÄsubprocessÄ£¿éÀ´ÊµÏÖ¡£
import sys
import subprocess
def RunShellWithReturnCode(command, print_output=False,
universal_newline ......
1 ÔÚÏëÒª²åÈë¶ÏµãµÄµØ·½²åÈë´úÂë
import pdb
pdb.set_trace()
2È»ºóʹÓÃÖ¸Áî½øÐÐdebug
²é¿´´úÂëÉÏÏÂÎÄ£¬l£¨Ð¡Ð´L£©
¼àÊÓ±äÁ¿ ......
pythonµÄC¡¢c++À©Õ¹
http://blog.chinaunix.net/u3/110228/showart_2148725.html
pythonµÄÇ¿´ó²»½ö±íÏÖÔÚÆä¹¦ÄÜÉÏ£¬¶øÇÒ»¹±íÏÖÔÚÆäÀ©Õ¹ÄÜÁ¦ÉÏ¡£
ʹÓÃC/C++ºÜÈÝÒ×±àдpythonµÄÄ£¿é£¬À©Õ¹pythonµÄ¹¦ÄÜ¡£
ͬʱ½«ÐÔÄÜÒªÇó±È½Ï¸ßµÄ´úÂëʹÓÃC/C++±àд£¬ÄܸüºÃµÄÃÖ²¹
½Å±¾ÓïÑÔÖ´ÐÐËÙ¶ÈÂýµÄȱÏÝ¡£
1. pythonµÄCÓïÑÔÀ©Õ¹
1.1 ......