首页
学习
活动
专区
工具
TVP
发布

我的博客

专栏作者
577
文章
915694
阅读量
39
订阅数
python关键字
and exec not assert finally or break for pass class from print continue global raise def if return del import try elif in while else is with except lambda yield
苦咖啡
2018-04-28
6820
安装python-mysqldb
pip install mysql-python 提示error: Unable to find vcvarsall.bat 解决方案:安装mingw(http://www.mingw.org/) 或者直接下载:https://sourceforge.net/projects/mysql-python/files/mysql-python/
苦咖啡
2018-04-28
1.4K0
Python列表、元组、字典操作
#!/usr/bin/python # -*- coding: UTF-8 -*- list1 = [1,2,'a', 'b'] seq = (1,4,5) print list1[2] #获取第三个元素(下标是从0开始) print list1[-3] #获取倒数第三个元素 print list1[2:] #获取第三个元素到最后一个 print len(list1) #获取列表元素个数 print max(list1) #获取最大的元素 print min(list1) #
苦咖啡
2018-04-28
1.6K0
Python文件操作
#!/usr/bin/python # -*- coding: utf-8 -*- import os path = os.getcwd() file_list = os.listdir(path) if '2.log' in file_list : os.remove(path + '/2.log') r_file = open(path + '/1.log') w_file = open(path + '/2.log', 'w') r_content = r_file.read() w_con
苦咖啡
2018-04-28
7790
Python字符串
# -*- coding: utf-8 -*- import re #字符串替换 str1 = 'hello world world world abc=123 abc=valu' #第一参数是被替换的字符串,第二个参数是新字符串,第三个是替换次数(默认替换全部) print str1.replace('world', 'Pythoner') old = re.compile("abc=\d{1,}") print old.sub("abc=234",str1) 字符串函数列表 函数名 参数 说明
苦咖啡
2018-04-28
7200
Python调用Shell命令–总有一款适合你
#!/usr/bin/python # -*- coding: utf-8 -*- import os import commands import subprocess # content = os.system('ls -al') #执行结果 0或者1 # print '结果:%s' % content # content = os.popen('ls -al').read() # print '###结果:%s' % content # content = os.popen('ls -al').re
苦咖啡
2018-04-28
7500
Python-MySQL查询函数使用示例
# -*- coding: UTF-8 -*- import MySQLdb import time #警告信息try except是无法捕捉的 from warnings import filterwarnings filterwarnings(‘error’, category = MySQLdb.Warning) cursor = conn = delete_id = update_id = 0 try: conn = MySQLdb.connect(host=’10.200.
苦咖啡
2018-04-28
1.5K0
Python操作MySQL数据库
数据库python-mysql安装参考:http://blog.phpfs.com/archives/2343.html # -*- coding: UTF-8 -*- import MySQLdb import time #警告信息try except是无法捕捉的 from warnings import filterwarnings filterwarnings('error', category = MySQLdb.Warning) cursor = conn = delete_id = update
苦咖啡
2018-04-28
1.1K0
Python警告信息捕捉
异常和警告处理案例 # -*- coding: UTF-8 -*- import MySQLdb #警告信息try except是无法捕捉的 from warnings import filterwarnings filterwarnings('error', category = MySQLdb.Warning) #当然也可以屏蔽警告filterwarnings("ignore") try: conn = MySQLdb.connect(host='127.0.0.1',user='test',p
苦咖啡
2018-04-28
1.5K0
supervisor安装和使用
1.介绍 Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动、重启、关闭进程(不仅仅是 Python 进程)。除了对单个进程的控制,还可以同时启动、关闭多个进程,比如很不幸的服务器出问题导致所有应用程序都被杀死,此时可以用 supervisor 同时启动所有应用程序而不是一个一个地敲命令启动。 2.Ubuntu14.04安装 sudo apt-get install supervisor 3.配置说明
苦咖啡
2018-04-28
9370
没有更多了
社区活动
腾讯技术创作狂欢月
“码”上创作 21 天,分 10000 元奖品池!
Python精品学习库
代码在线跑,知识轻松学
博客搬家 | 分享价值百万资源包
自行/邀约他人一键搬运博客,速成社区影响力并领取好礼
技术创作特训营·精选知识专栏
往期视频·千货材料·成员作品 最新动态
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档