首先说明,我写过几年的程序,今天突然想学python。
觉得不错,今天第一天学习
习惯搜索引擎,然后代码
还是经常出错提示,
所以跑来这里提问一下,希望大伙可以给我帮忙
我想写一个数据库连接
我已经装了MySQL-python-1.2.2.win32-py2.6.exe(没有重启,不知是否需要重启)
以下代码
# coding=utf-8
from MySQLdb import *
def conn():
cn=Connection('127.0.0.1','root','','test')
cur=cn.cursor()
cur.execute('select * from test')
row=cur.fetchone()
print row[0]
print row[1]
if __name__=='__main__':
conn()
以下报错
Traceback (most recent call last):
File "D:\py\test.py", line 2, in <module>
from MySQLdb import *
File "C:\Python26\Lib\site-packages\MySQLdb\__init__.py", line 34, in <module>
from sets import ImmutableSet
File "C:\Python26\lib\sets.py", line 85, in <module>
stacklevel=2)
File "C:\Python26\lib\warnings.py", line 29, in _show_warning
file.write(formatwarning(message, category, filename, lineno, line))
TypeError: idle_formatwarning_subproc() takes exactly 4 arguments (5 given)