随笔分类 -  Python实例

Python 发送邮件
摘要:#!/bin/python#coding=utf-8#导入smtplib和MIMETextimport smtplibfrom email.mime.text import MIMEText##############要发给谁mailto_list=["xxxx@gmail.com"]######################设置服务器,用户名、口令以及邮箱的后缀mail_host="smtp.163.com"mail_user="xxxx@163.com"mail_pass="xxxxx"mail_postfi 阅读全文

posted @ 2013-11-03 22:57 大 T 阅读(261) 评论(0) 推荐(0)

Python 日期处理
摘要:#!/bin/python#coding=utf-8from datetime import datetimefrom datetime import timedelta###################格式化输出 Begin#######################date>>stringnow = datetime.now()print now.strftime('%Y-%m-%d %H:%M:%S')#string>>datestr_date='2013-11-02 16:26:23'd=datetime.strptime( 阅读全文

posted @ 2013-11-02 22:49 大 T 阅读(564) 评论(0) 推荐(0)

实现简单的通讯录
摘要:简单的通讯录实现,A byte of Python的例子#!/bin/python#coding=utf8import ostry: import cPickle as pexcept: import pickle as pclass Person: def __init__(self,name,mobile='',email='',address=''): self.name = name self.mobile = mobile self.email = email self.address = address def modifyInfo( 阅读全文

posted @ 2013-10-30 23:05 大 T 阅读(271) 评论(0) 推荐(0)

创建文件备份
摘要:一个简单的例子,A byte of Python的例子,利用系统自带的命令创建某些文件的备份,放入指定的目录中import osimport timesource = ['/home/dat/python/test1','/home/dat/python/test2']target_dir = '/home/dat/python/'today = target_dir+time.strftime('%Y%m%d')now = time.strftime('%H%M%S')comment = raw_input(&# 阅读全文

posted @ 2013-10-30 21:35 大 T 阅读(212) 评论(0) 推荐(0)