ÔÚWindowsÉÏ°²×°Python+MySQL µÄ³£¼ûÎÊÌâ¼°½â¾ö·½·¨
ÑéÖ¤ÊÇ·ñÒѾ°²×°ÁËMySQLdb£º
==========================================================
d:\usr\local\Python25>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] onwin32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
==========================================================
Èç¹ûÓÐÀàËÆÓÚÉÏÃæµÄ"No module named MySQLdb"£¬±íÃ÷MySQLdbÉÐδ°²×°»ò°²×°µÄ²»³É¹¦£¡
MySQL °æ±¾£º5.0.67
ÏÂÔصØÖ·£ºhttp://dev.mysql.com/downloads/mysql/5.0.html#downloads
ÏÂÔØexeÎļþ²¢°²×°
==========================================================
Python °æ±¾£º2.5
ÏÂÔصØÖ·£ºhttp://www.python.org/download/releases/2.5.4/
ÏÂÔØmsiÎļþ²¢°²×°
MySQLdb°æ±¾£º MySQLdb Windows binary for Python 2.5
ÏÂÔصØÖ·£ºhttp://biohackers.net/wikiattach/Python2(2e)5/attachments/MySQL-python.exe-1.2.1_p2.win32-py2.5.exe
²Î¼û£ºhttp://forums.mysql.com/read.php?50,129618,140611#msg-140611
³£¼ûÎÊÌ⣺
1.ÎÞ·¨¶¨Î»³ÌÐòÊäÈëµã mysql_server_init ÓÚ¶¯Ì¬Á´½Ó¿â LIBMYSQL.dll ÉÏ¡£
----------------------------------------------------------------------------------------------------
D:\usr\local\Python25>python
Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\usr\local\Python25\Lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: ÕÒ²»µ½Ö¸¶¨µÄ³ÌÐò¡£
----------------------------------------------------------------------------------------------------
½â¾ö·½·¨£º°Ñmysql°²
Ïà¹ØÎĵµ£º
¡¡¡¡ÓÐʱºò£¬Òª°ÑÄÚ´æÖеÄÒ»¸ö¶ÔÏó³Ö¾Ã»¯±£´æµ½´ÅÅÌÉÏ£¬»òÕßÐòÁл¯³É¶þ½øÖÆÁ÷ͨ¹ýÍøÂç·¢Ë͵½Ô¶³ÌÖ÷»úÉÏ¡£PythonÖÐÓкܶàÄ£¿éÌṩÁËÐòÁл¯Óë·´ÐòÁл¯µÄ¹¦ÄÜ£¬È磺marshal, pickle, cPickleµÈµÈ¡£½ñÌì¾Í½²½²marshalÄ£¿é¡£
¡¡¡¡×¢Ò⣺
marshal²¢²»ÊÇÒ»¸öͨÓõÄÄ£¿é£¬ÔÚijЩʱºòËüÊÇÒ»¸ö²»±»ÍƼöʹÓõÄÄ£¿é£¬ÒòΪʹÓÃmarshalÐ ......
Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
# 024
dict1 = {
'5064001':'Mememe',
'5064002':'tutu',
'5064003':'thrthr',
'5064004':'fofo'
}
print dict1['5064003']
# Ò²¿ÉÒÔʹÓÃÕûÐÍ×÷ΪΨһµÄ±àºÅ
dict2 = {
5064001:'Mememe',
506400 ......
Ô´´úÂëÏÂÔØ£ºÏÂÔصØÖ·ÔÚÕâÀï
# 033
class Person:
age = 22
def sayHello(self): # ·½·¨Ó뺯ÊýµÄÇø±ðÔÚÓÚÐèÒªÒ»¸öself²ÎÊý
print 'Hello!'
# end of def
# end of class # ÕâÊÇÎÒÁ¼ºÃµÄ±à³Ì·ç¸ñ
p = Person()
print p.age
p.sayHello()
output£º
22
Hello! ......
# 040
import time
try:
f = file('040_Finally.py')
while True:
line = f.readline()
if len(line) == 0:
break
time.sleep(0.33)
print line,
# end of while
finally:
f.close()
print 'Closed the file.'
# end of try
output£º
> ......
¿ÉÒÔ²¥·Å´ó²¿·ÖµÄÒôÊÓƵ.
demo download: http://www.sandy1219.com/python/media.rar
playMP3.py
# -*- coding: utf-8 -*-
import wx;
import wx.media;
import os;
import SPrint;
import mediaStateBar;
import mediaList;
import SaveLog;
import MediaItem;
woldcart = "media files|*.*|avi ......