上一页 1 2 3 4 5 6 7 ··· 9 下一页
摘要: setatt r给对象的属性赋值,若属性不存在,先创建再赋值 用法 setattr(object, name, values) object -- 对象。 name -- 字符串,对象属性。 value -- 属性值。 阅读全文
posted @ 2018-09-14 16:36 米 立 阅读(318) 评论(0) 推荐(0) 编辑
摘要: #变量作用域规则 #python作用域的基础知识b='3'def f1(a): print a print bf1(1)#1,3 def f2(a): print a print b b=9#f2(1)#报错UnboundLocalError: local variable 'b' referenc 阅读全文
posted @ 2018-08-31 16:37 米 立 阅读(133) 评论(0) 推荐(0) 编辑
摘要: django: 返回中文字符串ok,返回json中文乱码 解:json.dumpd(dd,ensure_ascii=False) 模板继承报错 解:需要添加路径{%extends ./base.html%} python2.7 unicode和string类型 >>> ss=u'dddd'+'ddd 阅读全文
posted @ 2018-05-17 17:08 米 立 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 国内源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple 阿里云:http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 华中理工大学:htt 阅读全文
posted @ 2018-05-08 15:58 米 立 阅读(209) 评论(0) 推荐(0) 编辑
摘要: #coding=utf-8 #在类的继承中,如果重定义某个方法(比如下面例子中的greet方法),该方法会覆盖父类的同名方法,但有时, #我们希望能同时实现父类的功能,这时,我们就需要调用父类的方法了 ''' class Animal(object): def __init__(self,name): self.name=name def greet(self)... 阅读全文
posted @ 2018-04-25 14:42 米 立 阅读(154) 评论(0) 推荐(0) 编辑
摘要: (1)列表推导式和(2)生成器表达式(1)和(2)的区别是一个是一起再内存中全部生成,一个是用到的时候在生成>>> [i for i in range(10)] 标致是[] [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> (i for i in range(10)) 标致是() 阅读全文
posted @ 2018-04-24 13:35 米 立 阅读(166) 评论(0) 推荐(0) 编辑
摘要: mock的官网学习备忘录:官网地址https://docs.python.org/3/library/unittest.mock.html#quick-guide 1,安装 python3 unittest内置了mock,直接from unittest import mock就可以 2,简介 用mo 阅读全文
posted @ 2018-04-10 16:52 米 立 阅读(1963) 评论(0) 推荐(0) 编辑
摘要: 系统之前安装了python2.7,现在准备装个python3.6 1:首先下载一个python3.6适合windows32位的包python-3.6.5.exe 然后直接默认双击安装,安装的时候勾选add to path 默认安装路径C:\Users\Administrator\AppData\Lo 阅读全文
posted @ 2018-04-04 10:10 米 立 阅读(316) 评论(0) 推荐(0) 编辑
摘要: 安装: MySQL Installer 下载 mysql-installer-community-5.7.19.0.msi:https://dev.mysql.com/downloads/file/?id=471661 下载双击安装,如果报错,点击execute安装一些需要的软件 mysql启动报错 阅读全文
posted @ 2018-03-16 10:50 米 立 阅读(191) 评论(0) 推荐(0) 编辑
摘要: f.read() 整个文件读入到内存,全部放入到一个string中 f.readlines() 文件全部内容解析成行列表,自带\n,需要print i, f.readline()一行一行,返回字符串对象 阅读全文
posted @ 2018-03-13 10:53 米 立 阅读(260) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 9 下一页