随笔分类 -  [-011-]-python

摘要:1*1= 1 1*2= 2 1*3= 3 1*4= 4 1*5= 5 1*6= 6 1*7= 7 1*8= 8 1*9= 9 2*1= 2 2*2= 4 2*3= 6 2*4= 8 2*5=10 2*6=12 2*7=14 2*8=16 2*9=18 3*1= 3 3*2= 6 3*3= 9 3*4 阅读全文
posted @ 2018-08-21 14:57 旅行没有终点 阅读(305) 评论(0) 推荐(0)
摘要:1.常用异常: AttributeError 试图访问一个对象没有的树形,比如foo.x,但是foo没有属性xIOError 输入/输出异常;基本上是无法打开文件ImportError 无法引入模块或包;基本上是路径问题或名称错误IndentationError 语法错误(的子类) ;代码没有正确对 阅读全文
posted @ 2018-08-12 17:48 旅行没有终点 阅读(210) 评论(0) 推荐(0)
摘要:China 山东 加法 减法 <class '__main__.Provice'> csv 123456 <module 'test01' from 'F:\\myworkspacedirectory\\Function\\member\\test01.py'> <class 'test01.Pro 阅读全文
posted @ 2018-08-12 16:59 旅行没有终点 阅读(243) 评论(0) 推荐(0)
摘要:A、生成器(包含yield的就是生成器)def func(): print(11) yield 1 print(22) yield 2 print(33) yield 3 print(44) yield 4r=func()ret=r.__next__()print(ret)ret=r.__next_ 阅读全文
posted @ 2018-08-12 16:24 旅行没有终点 阅读(202) 评论(0) 推荐(0)
摘要:Cat的构造方法 A的构造方法 {'n': '猫', 'ty': '动物'} 阅读全文
posted @ 2018-08-10 19:01 旅行没有终点 阅读(206) 评论(0) 推荐(0)
摘要:一、反射:根据字符串的形式去对象(某个模块)中去操作成员通过字符串的形式,导入模块通过字符串的形式,去模块中寻找指定的函数,并执行1.__import__:用于字符串的形似执行导入模块 inp=input("请输入模块名:")#print(inp,type(inp))#__import__用于字符串 阅读全文
posted @ 2018-08-09 16:58 旅行没有终点 阅读(318) 评论(0) 推荐(0)
摘要:A、单文件日志 import logging#定义日志文件#文件格式logging.basicConfig(filename='log.log', format='%(asctime)s-%(name)s-%(levelname)s-%(module)s:%(message)s', datefmt= 阅读全文
posted @ 2018-08-08 17:14 旅行没有终点 阅读(269) 评论(0) 推荐(0)
摘要:import subprocess1.执行系统命令subprocess.call('ipconfig') #shell=False时,拼接命令分开写,放在列表中,等于True时,可写一块,空格隔开例子: subprocess.call(['ls','-l'],shell=False)subproce 阅读全文
posted @ 2018-08-08 11:45 旅行没有终点 阅读(464) 评论(0) 推荐(0)
摘要:'''A.shutil:高级的文件 文件夹 压缩包 处理模块'''import shutil'''1.copyfileobj(a1,a2,lenth):将文件内容拷贝到另一个文件中'''shutil.copyfileobj(open('old.xml','r'),open('new.xml','w' 阅读全文
posted @ 2018-08-08 10:24 旅行没有终点 阅读(488) 评论(0) 推荐(0)
摘要:配置文件ini [a1]age = 18sex = 'man'[a2]age = 19sex = 'woman'name = False 1、对配置文件进行操作 import configparsercon=configparser.ConfigParser()con.read("ini",enco 阅读全文
posted @ 2018-08-07 18:46 旅行没有终点 阅读(213) 评论(0) 推荐(0)
摘要:xml总结 1、解析 str 文件 tree,ElementTree,type root,Element,type2、操作 Element: tag,text,find,iter,get,set... 3、重新写入 tree.write() str没有tree >ElementTree(root) 阅读全文
posted @ 2018-08-06 17:17 旅行没有终点 阅读(619) 评论(0) 推荐(0)
摘要:{'status': 1000, 'desc': 'OK'} <class 'dict'> {"status": 1000, "desc": "OK"} <class 'str'> {"weatherinfo":{"city":"哈尔滨","cityid":"101050101","temp":"5 阅读全文
posted @ 2018-08-06 17:05 旅行没有终点 阅读(216) 评论(0) 推荐(0)
摘要:None F:/我的工作目录/QualityAssuranceDepartment/06workspace/05-xxxx/test-py3/Function/testmodul01.py lib F:\我的工作目录\QualityAssuranceDepartment\06workspace\05 阅读全文
posted @ 2018-08-05 20:08 旅行没有终点 阅读(163) 评论(0) 推荐(0)
摘要:报错如下图: 解决方法一: 鼠标移至报错处,按住Alt+enter键,选择ignore errors like this 方法二:找到设置File - Settings…… - Editor - Inspections中找到PEP8 coding style violation,在右下角ignore 阅读全文
posted @ 2018-08-05 17:52 旅行没有终点 阅读(13520) 评论(1) 推荐(0)
摘要:False True 阅读全文
posted @ 2018-08-03 14:51 旅行没有终点 阅读(272) 评论(0) 推荐(0)
摘要:import re'''正则表达式:re.match:从头匹配re.search:浏览全部字符串,匹配第一个符合规则的字符串re.findall():将匹配到得的所有内容都放置在一个列表中#re.finditer():re.split():re.sub():''''''1.match'''origin = "hello tom bcd tom lge tom acd 19"r=re.match("... 阅读全文
posted @ 2018-08-02 17:11 旅行没有终点 阅读(253) 评论(0) 推荐(0)
摘要:1.json序列介绍:提供4个关键字:dumps,dump,loads,load(与pickle用法完全相同) 语法:f.write(bytes(json.dumps(dict),encoding="utf-8")) r=json.loads(f.read().decode("utf-8")) 将字 阅读全文
posted @ 2018-08-02 10:25 旅行没有终点 阅读(158) 评论(0) 推荐(0)
摘要:1.pickle序列介绍:提供4个关键字:dumps,dump,loads,load 语法:f.write(pickle.dumps(dict))=pickle.dump(dict,f) "r=pickle.loads(f.read())" = "r=pickle.load(f) 将字典存入文件,由 阅读全文
posted @ 2018-08-02 09:29 旅行没有终点 阅读(513) 评论(0) 推荐(0)
摘要:goodbye! 阅读全文
posted @ 2018-07-31 16:47 旅行没有终点 阅读(312) 评论(0) 推荐(0)
摘要:A、time模块 1. sleep():强制等待 time.struct_time(tm_year=2018, tm_mon=7, tm_mday=31, tm_hour=7, tm_min=32, tm_sec=9, tm_wday=1, tm_yday=212, tm_isdst=0) time 阅读全文
posted @ 2018-07-31 15:30 旅行没有终点 阅读(272) 评论(0) 推荐(0)