随笔分类 - python
摘要:# import MySQL moduleimport MySQLdb# get user inputname = raw_input("Please enter a name: ")species = raw_input("Please enter a species: ")# connectdb = MySQLdb.connect(host="localhost", user="joe", passwd="secret",db="db56a")# create a cur
阅读全文
摘要:需要用到openpyxl这跟模块安装easy_install openpyxl使用方法from openpyxl.workbook import Workbookfrom openpyxl.writer.excel import ExcelWriterfrom openpyxl.cell import get_column_letterfrom openpyxl.style import Color, Fillfrom openpyxl.cell import Cell#新建一个workbookwb = Workbook()#第一个sheet是wsws = wb.worksheets[0]#设
阅读全文
摘要:import timeclienttime = '2012-04-12 08:35:33'servertime = '2012-04-12 13:35:34'##转化为时间戳c_time = time.mktime(time.strptime(clienttime,'%Y-%m-%d %H:%M:%S'))s_time = time.mktime(time.strptime(servertime,'%Y-%m-%d %H:%M:%S'))##求时间差time_diff = s_time - c_time##取当前时间 时间戳 se
阅读全文
摘要:import logginglogger = logging.getLogger("hello") # 生成一个名为hello日志对象 对象名可以为空logfile = '/home/x/mt4client/process_node.log'# logfile是一个全局变量,它就是一个文件名# 生成一个Handler。logging支持许多Handler,# 象FileHandler, SocketHandler, SMTPHandler等,我由于要写# 文件就使用了FileHandler。 handler = logging.FileHandler(log
阅读全文
摘要:1.下载apt-get install supervisor2.修改配置文件vim /etc/supervisor/supervisord.conf [program:process_node]command=python /home/x/mt4client/process_node.py -n ss1@127.0.0.1 -c 123456 2>&1 &autorstart=truestdout_logfile=/home/x/mt4client/log/process_node.log3.启动/etc/init.d/supervisor start启动的时候遇到错误S
阅读全文
摘要:Python MySQLdb escape_string 转义函数php mysql_escape_string
阅读全文
摘要:try: print "ok"except: import traceback traceback.print_exc() //print(traceback.format_exc())
阅读全文
摘要:# -*- coding: utf-8 -*-import smtplibfrom email.mime.text import MIMEText#要发给谁def send_mail(to_list,sub,content): #设置服务器,用户名、口令以及邮箱的后缀 mail_host="smtp.googlemail.com" mail_user="zhangce" mail_pass="123456" mail_postfix="gmail.com" me=mail_user+"<"
阅读全文

浙公网安备 33010602011771号