Jestin Blog

Python 下的文章

Jul 19 , 2018

Python tab 补全

1、通过导入sys模块来查看python的的环境变量 Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2 Type "help", "copyright", "credits" or &qu...
Jul 18 , 2018

Python列表切片

>>> name_list [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 'four', 'one', 'one', 'one', 'three', 'two', 'u', 'n', 1, 29, 30, 31]...
Jul 18 , 2018

Python列表

创建和插入 >>> name_list = ['one','two','three'] >>> name_list ['one', 'two', 'three'] >>> for i in range(30):name_list.append(i) ... >>> name_list ['one', 'two', 'thr...
Jul 18 , 2018

Python文件处理

创建、追加、读取 >>> f = file('user_list','a') >>> f.write('\nuser3 pass3') >>> f.close a 追加 w 创建 r 读取 wb rb二进制格式 a+ r+ 文件读取 >>> f = file('user_list') >>> f.rea...
Jul 18 , 2018

正则表达式re模块

#匹配字符串 import re 导入模块 p = re.compile(r'hello') 将正则表达式编译成p对象 match = p.match('hello world!') 使用p匹配文本,获得匹配结果,无法匹配是将返回None match ...
Jul 18 , 2018

Python-MySQL交互

软件包:MySQL-python-1.2.3.tar.gz 1、安装MySQL-Python yum install python-devel tar xvzf MySQL-python-1.2.2.tar.gz cd MySQL-python-1.2.3 修改site.cfg配置文件 vim site.cfg 把 mysql_config = /usr/local/mysql/bin/mysq...