python 随笔
# -*- coding: cp936 -*-
import os,sys,time,smtplib,poplib
#python -m Basehttpserver 80 在运行里面运行
#######################################
#以下为发送邮件
username="*****@126.com"
username2='****@qq.com'
passWord="****"
def sendmail():
smtp_server='smtp.126.com'
smtp = smtplib.SMTP(smtp_server)
smtp.login(username,password)
smtp.set_debuglevel(1)
smtp.sendmail(username,username2,'From:mailadmin@126.com,\rTo:******@qq.com\rSubject:helloe,\r\n\r\n...this is testing ')
a= smtplib.stat()
#print "sendmail,,,,OK !"
#print "sendmail,,,,Fail !"
smtp.quit()
#以下为接受邮件
def getmail():
print "请稍后,正在积极联系中,,,"
POP_server='pop.126.com'
pop=poplib.POP3(POP_server)
pop.user(username)
pop.pass_(password)
stat_=pop.stat()
list_=pop.list()
pop.retr(14)#根据邮件编号获取邮件内容
#pop.dele()#根据邮件编号将其标记为删除
print list_
pop.quit()
sendmail()
getmail
#####################################
print "当前目录路径:",os.getcwd()
print "当前目录下的文件和目录:"
f=open('E:\\1.txt','r+') #打开文件
f.seek(0)
print f.read() #读取整个文件
f.seek(0)
print f.readline() #返回文件第一行
f.seek(0)
print f.readlines() #返回文件所有行
f.seek(2) #移位到第15个字符
print f.readline()
print f.tell()
f.seek(0)
test = f.readlines()
for line in test:
print (line)
#line = int(line)
#print line * 2
#f.write(line * 2)
f.close() #关闭文件
#####################################
'''
九九乘法表如下:
1.
for m in range(1,10):
for n in range(1,10):
print(n,'*',m,'=',m*n,")
2.
for m in range(1,10):
for n in range(1,10):
if m<=n:
print(n,'*',m,'=',m*n," ",end="")
print("\n")
#3.
print("\n\t\t\t九九乘法表")
for m in range(1,10):
print(" ")
for n in range(1,m+1):
print(n,'*',m,'=',m*n," ",end="")
print("\n")
#####################################
'''
#pubic 函数:
def erro_1(a):
print("\t\t 该功能暂时无法使用!")
def chakan():
return "你选着【查看】"
def xiugai():
return "你选着【修改】"
def tianjia():
return "你选着【添加】"
def shanchu():
return "你选择【删除】"
def tuichu():
return "\t\t\t正在退出,,,,,,请稍后!"
def xz_pub(a):
su = {
1:["查看",chakan()],
2:["修改",xiugai()],
3:["添加",tianjia()],
4:["删除",shanchu()],
5:["退出",tuichu()]
}
print(su[a][0])
print(su[a][1])
def main():
print(time.strftime("%Y/%m/%d %H:%M:%S 星期%w") )
print(" 1.查看 2.修改 3.添加 4.删除 5.退出 ")
JC=[1,2,3,4,5,6]
xz=int(input("您的选着是:"))
pd=(xz in JC)
while True:
xz_pub(xz)
break
if __name__ == '__main__':
main()
相关文章