tr:nth-child(odd) > td,
.table-striped tbody > tr:nth-child(odd) > th {
background-color: #f9f9f9;
}

.table-celled.table tr td,.table-celled.table tr th {
border-left: 1px solid rgba(34,36,38,.1)
}

.table-celled.table tr td:first-child,.table-celled.table tr th:first-child {
border-left: none
}

.toc ul {
list-style: none;
}
p {
line-height: 1.6;
}
body>p {
margin-bottom: 1.8em;
}
body>p>img.center,
body>p>a>img.center {
display: block;
margin: 0 auto;
background-color: rgba(128,128,128,0.3);
}
body {
font-family: 'Helvetica Neue', helvetica, tahoma, arial, 'Hiragino Sans GB', stheiti, "Microsoft YaHei", "微软雅黑", 'WenQuanYi Micro Hei', stxihei, "华文细黑", heiti, "黑体", simsun, "宋体", song, sans-serif;
font-size: 1.15em;
font-weight: 100;
// line-height: 1.8em;
color: #2f2f2f;
}
em.cjk_emphasis{
font-style: normal;
font-family: georgia,"Times New Roman",times,"楷体","AR PL UKai CN", "NSimSun","Songti SC","SimSun",serif!important;
}
body dt,
body dd {
line-height: 1.35em;
}
body code, body .xiaoshujiang_code {
// background-color: #D6DBDF;
border: 0;
border-radius: 4px;
// color: #2C3E50;
font-size: 90%;
// padding: 2px 4px;
}
code {
background-color: #d6dbdf;
border-radius: 4px;
color: #2c3e50;
padding: 2px 4px;
}
.xiaoshujiang_code ol{
margin-bottom: 0px;
}
body h1 {
line-height: 1.6;
}
body h2 {
line-hieght: 1.1;
}
body h3 {
line-height: 1.1;
}

/**
* Treeview syntax highlighting based on highlight.js
* Copyright (c) 2014-2015, Asciidocfx Team, (MIT Licensed)
* https://github.com/asciidocfx/highlight-treeview.js
*/
.language-treeview.hljs{
position: relative;
}
.hljs-folder,
.hljs-hiddenfile,
.hljs-file {
position: relative;
vertical-align: top;
display: inline-block;
height: 16px;
}
.hljs-folder:before,
.hljs-file:before,
.hljs-hiddenfile:before {
top: 0;
content: '';
width: 14px;
height: 12px;
margin-top: 0px;
margin-right: 3px;
position: relative;
display: inline-block;
background-size: 14px;
background-repeat: no-repeat;
}
.hljs-file:before,
.hljs-hiddenfile:before {
height: 14px;
margin-left: 1px;
}
.hljs-hiddenfile {
opacity: 0.6;
}
.hljs-file.photo:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c5";
}
.hljs-file.plain:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f016";
}
.hljs-file.source:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c9";
}
.hljs-file.archive:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c6";
}
.hljs-file.audio:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c7";
}
.hljs-file.video:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c8";
}
.hljs-file.pdf:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c1";
}
.hljs-file.xls:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c3";
}
.hljs-file.doc:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c2";
}
.hljs-file.ppt:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f1c4";
}
.hljs-folder:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f114";
}
.hljs-hiddenfile:before {
font: normal normal normal 14px/1 fontawesome;
content: "\f016";
}
.hljs-tvline {
margin-left: 6px;
position: absolute;
text-indent: -99em;
padding-bottom: 8px;
vertical-align: top;
display: inline-block;
border-left-width: 1px;
border-left-style: solid;
border-left-color: rgb(94, 144, 117);
}
.hljs-folder-branch {
width: 8px;
height: 8px;
margin-top: -1px;
margin-left: 6px;
text-indent: -99em;
position: relative;
vertical-align: top;
display: inline-block;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(94, 144, 117);
}
.hljs-folder-branch.win {
width: 14px;
margin-right: 2px;
}
.hljs-folder-last-branch {
height: 7px;
width: 7px;
margin-left: 6px;
text-indent: -99em;
position: relative;
vertical-align: top;
display: inline-block;
border-bottom-width: 1px;
border-bottom-style: solid;
border-bottom-color: rgb(94, 144, 117);
border-left-width: 1px;
border-left-style: solid;
border-left-color: rgb(94, 144, 117);
}
.hljs-folder-last-branch.win {
width: 13px;
margin-right: 2px;
}

/**
* Treeview syntax highlighting based on highlight.js
*/

.mark{
border: 0;
background-color: #ddf3e7;
border-radius: 4px;
color: #29754d;
font-size: 90%;
padding: 2px 4px;
}
.line_mark{
border: 1px dashed #3a4c42;
}
code .mark, .xiaoshujiang_code .mark{
border-radius: 0px;
font-size: initial;
padding: initial;
}
a.attachment{
background-color: #ecf0f3;
border: 1px solid #bec6cb;
display: inline-block;
padding: 5px;
margin: 2px;
min-width: 250px;
}
a.attachment i.fa{
font-size: 3em;
float: left;
margin-right: 0.2em;
}
a.attachment .filename{
vertical-align: top;
text-align: left;
font-weight: bold;
}
a.attachment .filesize{
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
opacity: .6;
font-size: 80%;
white-space: nowrap;
}
.checkbox .checked{
text-decoration: line-through;
}
.flow-chart, .sequence-diagram{
text-align: center;
}
.plot, .plot-image{
text-align: center;
min-height: 200px;
min-width: 200px;
}

pre, .xiaoshujiang_pre {
line-height: initial !important;
word-wrap: break-word;
word-break: break-word;
}

.xiaoshujiang_pre {
margin: 1em 0px;
font-family: monospace;
white-space: pre;
}

.story_align_left, .story_align_left .story_image_container {
text-align: left;
}
.story_align_right, .story_align_right .story_image_container {
text-align: right;
}
.story_align_center, .story_align_center .story_image_container {
text-align: center;
}
.story_align_justify, .story_align_justify .story_image_container {
text-align: justify;
}

/**
* code line nums
*/
code.hljs.code_linenums, .xiaoshujiang_code.hljs.code_linenums{
position: relative;
}
.ol_linenums{
padding: 0px;
margin-left: 30px;
border-left: 1px solid #e0e0e0;
}
.li_linenum{
line-height: 20px;
margin-left: 10px;
list-style: none;
counter-increment: lines 1;
}
.li_linenum.li_list_style{
list-style: inherit;
margin-left: 5px;
}
.li_linenum:before, .li_linenum_before_span{
content: counter(lines, decimal);
position: absolute;
left: 0px;
text-align: center;
width: 2.5em;
opacity: 0.5;
vertical-align: top;
}
.li_linenum_before_span_hide{
display: none;
}
.xiaoshujiang_code .code_line_break_hack{
margin:0;
border:0;
border-top:0;
border-bottom:0;
}
/**
* code line nums
*/
.mathjax-container{
text-align: center;
}
div.mathjax{
max-width: 700px;
margin: 0 auto;
font-size: 14px;
}
text{
font-size: 14px;
}

/**
* block image
*/

.story_image_container{
text-align: center;
}
.story_image_container>.story_image{
display: inline-block;
position: relative;
max-width: 80%;
}
.story_image_caption{
border-bottom: 1px solid #d9d9d9;
display: inline-block;
color: #999;
padding: 10px;
}
.story_image_blank_caption{
border-bottom: 0px;
}
/**
.story_image:before, .story_image:after{
content: '';
position: absolute;
z-index: -2;
bottom: 13px;
left: 10px;
width: 50%;
height: 20%;
border-radius: 10px/90px;
box-shadow: 0 15px 10px rgba(0,0,0,0.7);
-webkit-transform: rotate(-3deg);
-moz-transform: rotate(-3deg);
-ms-transform: rotate(-3deg);
-o-transform: rotate(-3deg);
transform: rotate(-3deg);
}
.story_image:after {
right: 10px;
left: auto;
-webkit-transform: rotate(3deg);
-moz-transform: rotate(3deg);
-ms-transform: rotate(3deg);
-o-transform: rotate(3deg);
transform: rotate(3deg);
}

**/
.story_image>img{
border-radius: 0.3125em;
box-shadow: 0 2px 4px 0 rgba(34,36,38,.12),0 2px 10px 0 rgba(34,36,38,.08);
}
.story_inline_image>img{
max-width: 50%;
vertical-align: bottom;
}
.story_remote_resource_block{
text-align: center;
}
.xiaoshujiang_code_container {
position: relative;
padding-bottom: 2em;
}

.xiaoshujiang_code_title_container{
font-size: 70%;
opacity: 0.5;
}
.xiaoshujiang_code_title_container>.xiaoshujiang_code_infos{
float: right;
}

/*

Visual Studio-like style based on original C# coloring by Jason Diamond

*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
background: white;
color: black;
-webkit-text-size-adjust: none;
}

.hljs-comment,
.hljs-annotation,
.diff .hljs-header,
.hljs-chunk,
.apache .hljs-cbracket {
color: #008000;
}

.hljs-keyword,
.hljs-id,
.hljs-built_in,.css
.smalltalk .hljs-class,
.hljs-winutils,
.bash .hljs-variable,
.tex .hljs-command,
.hljs-request,
.hljs-status,
.nginx .hljs-title,
.xml .hljs-tag,
.xml .hljs-tag .hljs-value {
color: #00f;
}

.hljs-string,
.hljs-title,
.hljs-parent,
.hljs-tag .hljs-value,
.hljs-rule .hljs-value,
.ruby .hljs-symbol,
.ruby .hljs-symbol .hljs-string,
.hljs-template_tag,
.django .hljs-variable,
.hljs-addition,
.hljs-flow,
.hljs-stream,
.apache .hljs-tag,
.hljs-date,
.tex .hljs-formula,
.coffeescript .hljs-attribute,
.hljs-name {
color: #a31515;
}

.ruby .hljs-string,
.hljs-decorator,
.hljs-filter .hljs-argument,
.hljs-localvars,
.hljs-array,
.hljs-attr_selector,
.hljs-pseudo,
.hljs-pi,
.hljs-doctype,
.hljs-deletion,
.hljs-envvar,
.hljs-shebang,
.hljs-preprocessor,
.hljs-pragma,
.usertype,
.apache .hljs-sqbracket,
.nginx .hljs-built_in,
.tex .hljs-special,
.hljs-prompt {
color: #2b91af;
}

.hljs-phpdoc,
.hljs-dartdoc,
.hljs-javadoc,
.hljs-xmldoctag {
color: #808080;
}

.hljs-type,
.hljs-typename { font-weight: bold; }

.vhdl .hljs-string { color: #666666; }
.vhdl .hljs-literal { color: #a31515; }
.vhdl .hljs-attribute { color: #00b0e8; }

.xml .hljs-attribute { color: #f00; }
-->

1.内置函数补充

callable(object)
检查对象object是否可调用
1、类是可以被调用的
2、实例是不可以被调用的,除非类中声明了__call__方法

def f1():
print("test") f2 = "test" print(callable(f1))
print(callable(f2))
True
False

chr(i)
返回整数i对应的ASCII字符

print(chr(81))

print(chr(81))

odr(c)
参数c是一个ascii字符,返回值是对应的十进制整

print (ord('b'))

print (ord('b'))

随机验证码

import random
li = []
for i in range(5):
temp = random.randrange(65,91)
c = chr(temp)
li.append(c) result = "".join(li)
print(result)
 

compile(source, filename, mode[, flags[, dont_inherit]])
将source编译为代码或者AST对象。代码对象能够通过exec语句来执...
compile(source, filename, mode[, flags[, dont_inherit]])
中文说明:将source编译为代码或者AST对象。代码对象能够通过exec语句来执行或者eval()进行求值。
参数source:字符串或者AST(Abstract Syntax Trees)对象。
参数 filename:代码文件名称,如果不是从文件读取代码则传递一些可辨认的值。
参数model:指定编译代码的种类。可以指定为 ‘exec’,’eval’,’single’。
参数flag和dont_inherit:这两个参数暂不介绍,可选参数。

版本:在python2.3、2.6、2.7、3.2中均有不同,使用时要引起注意,兼容python3

英文说明:

Compile the source into a code or AST object. Code objects can be executed by an exec statement or evaluated by a call to eval(). source can either be a string or an AST object. Refer to the ast module documentation for information on how to work with AST objects.
The filename argument should give the file from which the code was read; pass some recognizable value if it wasn’t read from a file ('' is commonly used).
The mode argument specifies what kind of code must be compiled; it can be 'exec' if source consists of a sequence of statements, 'eval' if it consists of a single expression, or 'single' if it consists of a single interactive statement (in the latter case, expression statements that evaluate to something other than None will be printed).
The optional arguments flags and dont_inherit control which future statements (see PEP 236) affect the compilation of source. If neither is present (or both are zero) the code is compiled with those future statements that are in effect in the code that is calling compile. If the flags argument is given and dont_inherit is not (or is zero) then the future statements specified by the flags argument are used in addition to those that would be used anyway. If dont_inherit is a non-zero integer then the flags argument is it – the future statements in effect around the call to compile are ignored.
Future statements are specified by bits which can be bitwise ORed together to specify multiple statements. The bitfield required to specify a given feature can be found as the compiler_flag attribute on the _Feature instance in the future module.
This function raises SyntaxError if the compiled source is invalid, and TypeError if the source contains null bytes.
Note When compiling a string with multi-line code in 'single' or 'eval' mode, input must be terminated by at least one newline character. This is to facilitate detection of incomplete and complete statements in the code module.
Changed in version 2.3: The flags and dont_inherit arguments were added.
Changed in version 2.6: Support for compiling AST objects.
Changed in version 2.7: Allowed use of Windows and Mac newlines. Also input in 'exec' mode does not have to end in a newline anymore.

exec(r)
执行python代码,接收:代码或者字符串

exec(print("test"))

eval(s)
执行表达式,并且获取结果

eval(7*8)

dir(class)
快速查看,对象提供了哪些功能

dir(dict)

help(class)
获取帮助

help(dict)

divmod(d,d)
共:97,每页显示10条,需要多少页

n1 n2 = divmod(97, 10)

isinstance(instance,class)
用于判断,对象是否是类的实例

s = "test"
print(isinstance(s, str))

filter(函数, 可迭代对象)
循环第二个参数,让每个循环元素执行函数,如果函数返回值为True,则元素是合法的。

li = [ 1, 2, 3, 4 ]
ret = filter(None, li)
print(list(ret))

lamda()
默认返回结果为返回值

map(函数,可迭代的对象(可以for循环的东西))
可迭代对象每个元素应用到函数中,返回结果为列表。

filter()     #函数返回True,将元素添加到结果中
map()     #将函数返回值添加到结果中

globals()
所有的全局变量
locals()
所有的局部变量

hash(s)
转换成hash值,一般用于字典的key

len(s)
返回一个对象的长度

s = "字符"
print(len(s))
b = bytes(s, encoding = "utf-8")
print(len(b))

max([list])
返回列表中的最大值

li = [11, 22, 33]
r = max([li])

zip()
将列表的每列值组成一个无组

x = [1, 2, 3]
y = [4, 5, 6]
z = [7, 8, 9]
xyz = zip(x, y, z)
print xyz
[(1, 4, 7), (2, 5, 8), (3, 6, 9)]

2.Alex鸡汤

推荐书:《林达看美国》

json.loads(s)
将一个字符串,转换成python的基本数据类型,字符串形式的字典必须是双引号引用key value

3.装饰器

装饰器,我的理解是在不影响原函数的情况下(包括执行过程,返回结果,返回值等),增加其它功能(原函数前或后),即达到在不修改原代码的前提下,实现增加的功能。

所以,其优点有:

1.代码修改量小,不影响原函数内部逻辑等;

2.不修改原函数代码,避免原功能因代码语法性错误;

3.灵活性强,在需要增加功能的函数前加简单代码就行;

#def outer(func):
# print(123,func)
#def outer(func):
# return "111"
def outer(func):
def inner(*args,**kwargs): #支持不定传参
print("before")
r = func(*args,**kwargs) #返回原函数返回值
return r #返回原函数返回值
print("after")
return inner # @ + 函数名
# 功能:
# 1. 自动执行outer函数并且将其下面的函数名f1当作参数传递
# 2. 将outer函数的返回值,重新赋值给f1 @outerdef f1():
print("F1")

Python学习记录day4的更多相关文章

  1. Python学习记录day6

    title: Python学习记录day6 tags: python author: Chinge Yang date: 2016-12-03 --- Python学习记录day6 @(学习)[pyt ...

  2. Python学习记录day5

    title: Python学习记录day5 tags: python author: Chinge Yang date: 2016-11-26 --- 1.多层装饰器 多层装饰器的原理是,装饰器装饰函 ...

  3. Python学习记录day8

    目录 Python学习记录day8 1. 静态方法 2. 类方法 3. 属性方法 4. 类的特殊成员方法 4.1 __doc__表示类的描述信息 4.2 __module__ 和 __class__ ...

  4. Python学习记录day7

    目录 Python学习记录day7 1. 面向过程 VS 面向对象 编程范式 2. 面向对象特性 3. 类的定义.构造函数和公有属性 4. 类的析构函数 5. 类的继承 6. 经典类vs新式类 7. ...

  5. Python学习记录:括号配对检测问题

    Python学习记录:括号配对检测问题 一.问题描述 在练习Python程序题的时候,我遇到了括号配对检测问题. 问题描述:提示用户输入一行字符串,其中可能包括小括号 (),请检查小括号是否配对正确, ...

  6. 实验楼Python学习记录_挑战字符串操作

    自我学习记录 Python3 挑战实验 -- 字符串操作 目标 在/home/shiyanlou/Code创建一个 名为 FindDigits.py 的Python 脚本,请读取一串字符串并且把其中所 ...

  7. 我的Python学习记录

    Python日期时间处理:time模块.datetime模块 Python提供了两个标准日期时间处理模块:--time.datetime模块. 那么,这两个模块的功能有什么相同和共同之处呢? 一般来说 ...

  8. Python 学习记录

    记录一些 学习python 的过程 -------------------------------------- 1. 初始学习 @2013年10月6日 今天开始学习python 了 遇到好多困难但是 ...

  9. python学习记录_IPython基础,Tab自动完成,内省,%run命令_

        这是我第一次写博客,之前也有很多想法,想把自己所接触的,以文本的形式储存,总是没有及时行动.此次下定决心,想把自己所学,所遇到的问题做个记录共享给诸位,与此同时自己作为备忘,感谢各位访问我的博 ...

随机推荐

  1. QRCode

    这个星期, 领导要我总结项目中用到的一些技术, 然后交付文档. 嘿嘿, 奉命整理. 二维码, 相信很多项目中都会要求生成这个, 然后由手机端去扫描, 或存储一些详情信息, 或存储一条链接, 可以快捷访 ...

  2. SQL语句分组排序,多表关联排序

    SQL语句分组排序,多表关联排序总结几种常见的方法: 案例一: 在查询结果中按人数降序排列,若人数相同,则按课程号升序排列? 分析:单个表内的多个字段排序,一般可以直接用逗号分割实现. select ...

  3. 1、怎样设置C#OpenFileDialog(文件选择窗体)的指定路径、文件格式等属性(设置打开默认路径、文件格式、窗体显示文本)

    C#的OpenFileDialog的常用属性设置 1.设置属性 1)设置弹出的指定路径(绝对路径.相等路径) 2)设置标题 3)设置文本格式 2.打开方式1(绝对路径) 2.1) 打开的路径

  4. Git 获取文件操作

    1. 在本地新建存放源代码的文件夹: 2. 进入文件夹下,右击选择 Git Bash Here ,弹出git命令行窗口: 3. 运行指定 git init,初始化git: 4. git  remote ...

  5. 数据结构:链表(python版)续:带有尾节点引用的单链表

    #!/usr/bin/env python # -*- coding:utf-8 -*- from chapter3.single_linked_list import LNode,LinkedLis ...

  6. [moka同学笔记]六、Yii2.0课程笔记(魏曦老师教程)[徽章气泡]

  7. 魔术方法__sleep 和 __wakeup

    感觉序列化和反序列化用得倒是比较少了,而json_encode和json_decode用得相对多,都是转化成串,进行入库.传输等.json更方便,但是序列化和反序列化结合这两个魔术方法使用倒还行< ...

  8. 【夯实PHP基础系列】JQuery easyUI的使用

    最近在做一个公司的后台项目中,接触到 JQuery easyUI前端框架,被她简洁的代码和简单有效的ajax交互所深深吸引. 体会有以下3个方面: 1)快速创建表格的能力: 后端程序,比如PHP只需要 ...

  9. Lind.DDD敏捷领域驱动框架~Lind.DDD各层介绍

    回到目录 Lind.DDD项目主要面向敏捷,快速开发,领域驱动等,对于它的分层也是能合并的合并,比之前大叔的框架分层更粗糙一些,或者说更大胆一些,在开发人员使用上,可能会感觉更方便了,更益使用了,这就 ...

  10. ul ol di三者区别

    1.ul是无序列表,也就是说没有排列限制可以随意加li: <ul> <li>可以随意放置</li> <li>可以随意放置</li> < ...