This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
语法 描述 | |
$(this) 当前 HTML 元素 | |
$("p") 所有 <p> 元素 | |
$("p.intro") 所有 class="intro" 的 <p> 元素 | |
$(".intro") 所有 class="intro" 的元素 | |
$("#intro") id="intro" 的元素 | |
$("ul li:first") 每个 <ul> 的第一个 <li> 元素 | |
$("[href$='.jpg']") 所有带有以 ".jpg" 结尾的属性值的 href 属性 | |
$("div#intro .head") id="intro" 的 <div> 元素中的所有 class="head" 的元素 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//string:字符串表达式包含要替代的子字符串。 | |
//reallyDo:被搜索的子字符串。 | |
//replaceWith:用于替换的子字符串。 | |
String.prototype.replaceAll = function(reallyDo, replaceWith, ignoreCase) { | |
if(!RegExp.prototype.isPrototypeOf(reallyDo)) { | |
return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith); | |
} else { | |
return this.replace(reallyDo, replaceWith); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//int型转换成string型 | |
var x=100 | |
a = x.toString() | |
var x=100; | |
a = x +""; //JS会自动隐性转换 | |
//将string 变成 int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//操作字典 | |
var dic = new Array();//通过申明一个Array来做一个字典 | |
字典中项的遍历 | |
for (var key in dic) { | |
console.log(key + ":" + dic[key]); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onLoginSuccess = function (data) { | |
console.log(data); | |
}; | |
//页面中DOM结构加载完后,直接执行 | |
$(function() { | |
var ajaxObj = { | |
type: 'GET', | |
url: 'http://127.0.0.1:8000/api/albumstyles', //URL上一定要带HTTP,不然报错 | |
success: onLoginSuccess, //ajax成功,前端的回调函数 | |
dataType: "json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image as ImagePIL | |
def gen_thumb_image(path, width=0, height=0, filetype='JPEG'): | |
''' | |
生成缩略图 | |
''' | |
width = min(1024, width) | |
height = min(1024, height) | |
img = ImagePIL.open(path) | |
if width and not height: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com django |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 生成 requirements.txt 文件 | |
pip gamepy27 > requirments.txt | |
# 安装 requirements.txt 中的依赖 | |
pip install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 查看磁盘的使用情况以及文件系统被挂载的位置 | |
df -lh | |
Filesystem 容量 已用 可用 已用% 挂载点 | |
/dev/hda8 11G 6.0G 4.4G 58% / | |
# 列出机器中所有磁盘的个数,也能列出所有磁盘分区情况 | |
fdisk -l | |
# 磁盘信息 | |
Disk /dev/sda: 299.4 GB, 299439751168 bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distutils.sysconfig import get_python_lib | |
print(get_python_lib()) |