python
共 2 篇文章
python cookbook(1)
#coding=utf8 #1.4 对准:字符串长度为参数定义的,字符的位置由函数决定 print '|', 'hej'.ljust(20), '|', 'hej'.rjust(20), '|', 'hej'.center(20), '|' #1.5 删除首尾的字符,默认不带参数是删除首尾的空格。参数为字符串时,表明要删除的首尾的字符(只要这个字符在参数这个字符串里) x = ' hej ' print '|', x.lstrip(), '|', x.rstrip(), '|', x.strip(''), '|' x = 'xyxxyy hejyx yyx' print '|'+x.lstr…
2009-04-16 17:23 · python
python下读取邮件列表,并过滤邮件,然后调用网页发短信
#!/usr/bin/python #coding=utf8 import poplib import email import cPickle as pickle from email.Header import decode_header import urllib def getMails(keymap={},userinfo=[]): emailServer = poplib.POP3('mail.domain.com') emailServer.user(userinfo[0]) emailServer.pass_(userinfo[1]) mailinfo=[] # 遍历邮件 f…
2008-10-15 17:37 · python