易截截图软件、单文件、免安装、纯绿色、仅160KB

在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入门的36个例子 之 18

例1:
# _018
# This is a module (if write Chinese in a module, there will be a error)
def func1():
print 'This is function 1.'
def func2():
print 'This is function 2.'
def func3():
print 'This is function 3.'
# 019
# 使用“import”语句调用模块:
import _018_Module
_ ......

Python入门的36个例子 之 23

源代码下载:下载地址在这里
# 026
aList = ['1','2','3','4']
aListCopy = aList # 其实,这里仅仅复制了一个引用
del aList[0]
print aList
print aListCopy # 两个引用指向了了同一个对象,所以打印结果一样
aListCopy = aList[:] # 这是复制整个对象的有效方法
del aList[0]
print aList
print aListCopy
......

Python入门的36个例子 之 25

源代码下载:下载地址在这里
# 028
consoleInput = raw_input('请输入点什么吧:')
aFile = file(r'C:\out.txt', 'w')
aFile.write(consoleInput + '\n')
aFile.write('这里是第二行')
aFile.close()

output:
>>>
请输入点什么吧:haha
>>>
......

Python入门的36个例子 之 27

源代码下载:下载地址在这里
e.g.1
# 030
aFile = file(r'C:\temp.txt', 'a')
aFile.write('又添加了一行。')
aFile.close()

output:
e.g.2
# 030
aFile = file(r'C:\temp.txt', 'a')
aFile.write('又添加了一行。')
aFile.close()

output:
e.g.3
实现根据原始文件有没有最后一行空行的情况来进行&ldqu ......

Python入门的36个例子 之 34

源代码下载:下载地址在这里
raise有两个参数,第一个是由我们自己定义的异常类型,第二个是关于此异常的少量说明信息。
# 038
def getAge():
age = input('Input your age:')
if (age < 0 or age > 160):
raise 'BadAgeError', 'It is impossible!!!!!'
# end of if
return age
# ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号