PREPARE:
- xlrd包
下载 https://pypi.python.org/pypi/xlrd (VERSION2.6, 2.7, 3.2+)
安装 http://huaxia524151.iteye.com/blog/1173828 - mysql-connector-python
下载 http://dev.mysql.com/downloads/connector/python/1.0.html
安装 双击下载文件即可
LEARN:
- 字符串和数字的转换
字符串->数字 int(string) string可以是字符串变量或者是一个字符串
数字->字符串 str(num) num可以是数字变量或者是一个数字字符串 字符串操作
http://www.cnblogs.com/huangcong/archive/2011/08/29/2158268.htmlMySQL Python 教程 http://kodango.com/mysql-python-tutorial-part-one
- dict 中的 zip
https://docs.python.org/2/library/stdtypes.html?highlight=dict#dict.items
http://www.cnblogs.com/BeginMan/archive/2013/03/14/2959447.html
>>> a = dict(one=1, two=2, three=3)
>>> b = {'one': 1, 'two': 2, 'three': 3}
>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
>>> d = dict([('two', 2), ('one', 1), ('three', 3)])
>>> e = dict({'three': 3, 'one': 1, 'two': 2})
>>> a == b == c == d == e
True python使用mysql数据库
http://www.cnblogs.com/fnng/p/3565912.html6.python之xlwt模块列宽width、行高Heights详解
http://www.knowsky.com/886361.html
ERROR:
- unexpected indent: http://dikar.iteye.com/blog/308934
- SyntaxError{invalid syntax:
1.检查缩进
2.检查错误附近有没有少写 ‘(‘, ‘)’, ‘:’这些符号 建表 (#1064 - You have an error in your SQL syntax; check the manual that correspond )
检查sql语句,表名,列名不能是关键字,标点符号不要写错,表名不能是纯数字-_-notepad++炸了
注意及时备份,及时备份TypeError: list indices must be integers, not str
indices – index 的复数,所以以上意为数组索引一定是整数值,不能是字符串UnboundLocalError: local variable ‘sql’ referenced before assignment
存在未声明就使用的变量‘sql’,定义一下就完了
本文介绍了如何使用Python的xlrd库读取Excel文件,并通过mysql-connector-python库将数据导入MySQL数据库。内容包括字符串和数字的转换、MySQL Python教程、dict的zip操作以及处理常见的编程错误,如缩进错误、语法错误和类型错误。

4369

被折叠的 条评论
为什么被折叠?



