Python自动化开发
douyunqian668
这个作者很懒,什么都没留下…
展开
-
购物小程序
1.用户启动时先输入工资。1.用户启动程序后打印商品列表2.允许用户选择够买商品。3.允许用户不断的购买各种商品,4.购买时,检测剩余金额是否足够,如果足够直接扣款,否则打印金额不足允许用户主动退出程序,退出时打印已经购买的商品列表,原创 2016-06-25 17:00:57 · 450 阅读 · 0 评论 -
day03_set讲解(01)
1.学习方法:先写笔记后写作业2.上节课回复Python中最基本的数据类型:strtupledictlist新补充set集合函数分为自定义函数和Python的内置函数深拷贝和浅拷贝装饰器set 表示是一个无序且不重复例如set={"123","234","3444"}类里面有什么功能,就可以调用啥功能创建列表有两种方式第一种是原创 2016-06-26 14:51:27 · 264 阅读 · 0 评论 -
python解析邮件
__author__ = 'Administrator'import os,sys,stringimport poplib,email#服务端口Host="pop3.163.com"#用户名username="[email protected]"#密码password="“#创建一个Pop3对象这个时候实际上已经连接好桑了pop=poplib.POP3(原创 2016-06-26 23:53:42 · 2124 阅读 · 2 评论 -
day_03函数编程 三元符和lambda
1.三元运算:例子name="Alex" if 1==2 else "Min"print(name)运算输出:Min2.lambda运算f2=lambda x:x+200print(f2(300))f3=lambda a,a2=3:a+a2+3print(f3(1))print(f3(1,5))输出:50079原创 2016-06-27 21:46:59 · 287 阅读 · 0 评论 -
day_03_内置函数
例子:print(abs(-1))#求绝对值的#false: "" 0,[],{},Noneprint(bool(""))#如果all里面的参数全部都是真的话,这个返回值就是真的c=all([1,2,3,4])print(c)#对于any来说,参数只要有真就为真d=any([[],1,None])print(d)s="黎明"c=byt原创 2016-06-27 22:28:57 · 246 阅读 · 0 评论 -
day_03文件操作模式
r=open("db","r")f.close()r读出来的是字符串rb读出来的是字节w=open("db","wb")w.write(bytes("中国",encoding=“utf-8”))w.close()r+w+a+x+二进制的是:r+bx+bw+ba+bf=open("db","r+",encoding="utf原创 2016-06-28 15:46:15 · 243 阅读 · 0 评论 -
day04_python random模块随机生成验证码
1.例子:import randomli=[]for i in range(6): temp=random.randrange(65,91) li.append(chr(temp))print(li)result="".join(li)print(result)result=""for j in li: result+=jpri原创 2016-06-29 20:41:55 · 321 阅读 · 0 评论 -
day_04_python内置函数01
例子 complie eval exec s="print(1+2)"r=compile(s,"","exec")#把字符串变成Python代码print(r)exec(s)exec("8+8")#可以执行但是没有返回值的g=eval("8*8")#可以执行一个表达式并返回值print(g)dri(list)显示某个函数具有多少个内置方法help(原创 2016-06-29 22:26:35 · 300 阅读 · 0 评论 -
python时间模块处理
s="2016-07-11 17:56:57"import timec=time.strptime(s,"%Y-%m-%d %H:%M:%S")#将字符串的时间弄成日期格式print(c)d=time.mktime(c)#把日期格式弄成可以比较时间大小的东西print(d)原创 2016-07-11 21:29:02 · 377 阅读 · 0 评论 -
day04_filtter() 和map函数
result=filter(lambda a:a>80,[11,22,33,44,55])print(list(result))demo=map(lambda a:a+30,[22,33,44,55])print(list(demo))2.NAME="ALXE"def show(): s=123 c=123 print(locals())#返回本脚本的所有原创 2016-06-30 17:15:08 · 759 阅读 · 0 评论 -
python3的默认编码
__author__ = 'Administrator'#coding=utf-8#python3默认都是Unicode格式的汉字import syss=u"中国"print(type(s))# print(type(s.encode("utf-8")))s_utf_8=s.encode("utf-8")print(s_utf_8)#做成字节了print(sys.g原创 2016-07-12 22:48:24 · 3855 阅读 · 0 评论 -
day_04装饰器,返回值,参数
返回值例子def outer(func): def inner(): print("before") r=func() print("end") return r return inner@outerdef f1(): print("F1") return "砍人"原创 2016-06-30 23:23:11 · 338 阅读 · 0 评论 -
day_05双层装饰器
__author__ = 'Dou Yun Qian'#coding: utf-8USER_INFO={"Login_status":False}def check_login(func): def inner(*args,**kwargs): if USER_INFO.get("Login_status",None)==True: func原创 2016-07-01 10:58:21 · 253 阅读 · 0 评论 -
day04_装饰器
def outer(func): def inner(): print("log") ret=func() print("Hello") return ret return inner@outer#自动执行outer函数,切记outer函数一定要在使用它的函数的前面def f2(): print("F2"原创 2016-06-30 17:39:09 · 258 阅读 · 0 评论 -
day_05双层装饰器原理_字符串格式化
1.执行是从外层调用里层2.调用有返回值,从最里面往最外面返回,3.#+号不能用于d的前面 下面的10代表的是占位符 如果是正数,代码 ,如果参数是正数,则前面加+号s="发发发发发发斯蒂芬的地方 %(name)-10s fsdfsd%(age)+10d"%({"name":"agex","age":50})print(s)发发发发发发斯蒂芬的地方 agex fs原创 2016-07-01 12:36:16 · 288 阅读 · 0 评论 -
day07_configParser模块学习之一
#coding=utf-8import configparserconfig=configparser.ConfigParser()config.read("new",encoding="utf-8")ret=config.sections()#获取节点print(ret)keys=config.items("section1")#获取指定节点下的键值对print(ke原创 2016-07-25 22:46:22 · 266 阅读 · 0 评论 -
day07_configparser
# coding=utf-8import configparsercong=configparser.ConfigParser()cong.read("new",encoding="utf-8")# cong.add_section("section3")#添加一个节点# cong.add_section("section1")# cong.write(open("new"原创 2016-07-25 23:04:36 · 242 阅读 · 0 评论 -
day——05 迭代器,生成器
__author__ = 'Administrator'#format字符串格式化#例子s1="fdsfdsfs{0},Im a {0},I am".format("123","Dou")s2="-----{name:s}====={age:d}============{name:s}".format(name="Alex",age=26)#上面的s代表字符串,d代表数字s原创 2016-07-03 21:41:24 · 259 阅读 · 0 评论 -
day_05模块
import sysfor item in sys.path: print(item输出D:\Users\Administrator\PycharmProjects\Python03这个是开发软件自己带的原创 2016-07-03 22:12:17 · 192 阅读 · 0 评论 -
day06_python正则分组
1.分组就是去已经提取到的数据中再去提取数据2.import reorign="has fjsdkjfsdkjfksd"mm=re.match("h(?P\w+)",orign)print(mm.group())#获取所有的匹配结果print(mm.groups())#获取模型中匹配到的结果print(mm.groupdict())#依次输出的结果:原创 2016-07-14 23:51:32 · 251 阅读 · 0 评论 -
day07_XML模块
1.公司的配置文件 XML ,configparse类样式的文件2.XML文件格式一种是字符串类型的文件格式,另一种是文件,内部数据XML文件#__author__ = 'DouYunQian'# coding=utf-8from xml.etree import ElementTree as eltree=el.parse(r"C:\Jv\day07\s原创 2016-07-26 10:30:14 · 270 阅读 · 0 评论 -
day07_xml模块学习03
#__author__ = 'DouYunQian'# coding=utf-8from xml.etree import ElementTree as tf=open("C:\Jv\day07\src\Data\learn.xml", mode='r').read()d=t.XML(f)#print(c.tag)#这种方法不用getroot()而是直接读取的就是根节点原创 2016-07-26 11:11:07 · 300 阅读 · 0 评论 -
day07_subprocess模块学习
在Python3中使用subprocess一统了系统发送命令的代码#__author__ = 'DouYunQian'# coding=utf-8import subprocess#ret=subprocess.call("appium",shell=True)#返回状态吗的命令# print(type(ret))#ret1=subprocess.check_cal原创 2016-07-26 14:08:32 · 271 阅读 · 0 评论 -
day_05_pickel 和 json
import picklel=[11,22,33]pickle.dump(l,open("db","wb"))result=pickle.load(open("db","rb"))print(result)#pickle是Python独有的#而json是Python和其它语言交互的模块原创 2016-07-04 21:29:57 · 219 阅读 · 0 评论 -
day_05 time 模块
__author__ = 'Administrator'#python time 模块import timeprint(time.time())#返回当前的时间print(time.ctime(time.time()-8600))trs=time.gmtime()#可以拆开里面的值print(trs.tm_year,trs.tm_mon)print("{原创 2016-07-04 23:00:37 · 296 阅读 · 0 评论 -
Python day01周
1.Python的局势:很有前景2.Python字符串命名不可以包含数字下划线等开头驼峰命名法user_name="bobo3520"下划线命名法3.基本的判断if (条件): 执行语句else: 执行语句if (条件): 执行语句elif(条件): 执行语句elif(条件): 执行语句...原创 2016-06-18 10:26:34 · 237 阅读 · 0 评论 -
day07_xml学习
新建一个xml文件# coding=utf-8from xml.etree import ElementTree as etfrom xml.dom import minidom# tree=et.parse("xo.xml")# root=tree.getroot()# # rootf=et.Element("Alex2",{"k1":"a1"})# child_ro原创 2016-07-27 22:28:41 · 303 阅读 · 0 评论 -
day07_shutil模块学习
# coding=utf-8import shutil#shutil.copyfileobj(open("xo.xml","r"),open("xocopy.xml","w"))#拷贝一个文件对象# shutil.copyfile("new","new_copy")#拷贝一个文件# shutil.copymode("new","new_copy")#拷贝文件权限# shuti原创 2016-07-27 23:32:21 · 289 阅读 · 0 评论 -
day_07 zipfile模块学习
# coding=utf-8import zipfile# jk=zipfile.ZipFile("pp.zip","w")# jk.write("xo.xml")# # jk.write(r"new.xml")# jk.close()jk=zipfile.ZipFile("pp.zip","r")# jk.extractall()#for i in jk.na原创 2016-07-27 23:38:55 · 237 阅读 · 0 评论 -
Python __init__模块
如果在该文件中写入了import 包里面的各种模块,那样在使用该模块内的东西直接 from package import *原创 2016-07-19 09:53:35 · 265 阅读 · 0 评论 -
day06_python反射
#反射就是利用字符串的形式去模块里面找对应的函数import commontsdef run(): ind=input("请输入你要进入的模块") if hasattr(commonts,ind):#查找字符串对应的函数是否存在 func=getattr(commonts,ind)#返回一个函数体 func()原创 2016-07-28 20:48:36 · 236 阅读 · 0 评论 -
Python 类的静态字段和静态方法
class Person: test=u"我是静态字段" def __init__(self,name): self.name=name print(u"我是构造函数") def hello(self): print("Hello World") @staticmethod def printf():原创 2016-07-19 17:23:34 · 420 阅读 · 0 评论 -
day_06_反射01
__author__ = 'Administrator'import commontsimport logginglogging.basicConfig(filename="debug.txt", level=logging.INFO, format="%(asctime)s %(message原创 2016-07-08 20:56:33 · 307 阅读 · 0 评论 -
day06_反射02
__author__ = 'Administrator'import logginglogging.basicConfig(filename="debug.txt", level=logging.INFO, format="%(asctime)s %(message)s",原创 2016-07-08 21:16:54 · 251 阅读 · 0 评论 -
day__06反射总结
反射实例Web框架的路由系统反射:基于字符串的形式去模块中操作成员getattr setarrt delattr hasattr拓展:导入模块 __import__("模块名字")__import__("libs.模块名字",fromlist=True)原创 2016-07-08 21:33:55 · 249 阅读 · 0 评论 -
day_06python模块学习01
__author__ = 'Administrator'import os'''豆云谦模块内置'''import s3#print(vars(s3))#可以查看这个模块内有多少变量print(__doc__)#显示文件的注释print(__file__)#当前文件所在的路径print(os.path.abspath(__file__))print(os.原创 2016-07-08 22:04:44 · 193 阅读 · 0 评论 -
day06__模块特殊变量2
print(__package__)from bin import adminprint(admin.__package__)#查看导入文件的包名字print(__name__)#只有执行当前文件时等于__main__否则不等于原创 2016-07-08 22:31:57 · 215 阅读 · 0 评论 -
day07_ __import__
使用__import__ 导入模块的时候,模块的常量不能正确引用要使用from bao import 模块才可以使用原创 2016-07-31 10:15:20 · 236 阅读 · 0 评论 -
day08 pickle实力
s1。py中的代码:class Foo: def __init__(self,name): self.name=nameimport pickleobj=Foo("Git")pickle.dump(obj,open("qb","wb"))s2中的代码为:import picklefrom s1 import Fooobj=原创 2016-08-04 16:42:31 · 192 阅读 · 0 评论 -
day10————python作业socket
1.Socket发送两个东西 字符串文件2.subprocess在Windows中的编码是gbk的形式,所以获取后应该改变下.原创 2016-08-16 16:03:45 · 257 阅读 · 0 评论