- windows杀掉进程
C:\Users\j00113584>taskkill /F /PID 6848
成功: 已终止 PID 为 6848 的进程。
- python中的布尔操作
- js中的undefined
- python中的对象属性访问
python对象中的属性可以通过点访问符访问,点后直接跟属性名字,如:
x=obj.attr1
但是跟变量名是不行的
var attr=attr1
x=obj.attr //这种方式是不行的
这时可借助
getattr函数
var attr=attr1
x=getattr(obj,attr) //效果等同于obj.attr1
- 鼠标滑过事件:hover
$(selector).hover(function(){
//鼠标移到该组件上方
},function{
//鼠标离开该组件
});
- js中的多行文本赋值
var nm=function(){/*{% include "sources/dbfiles/inc/selmap.html" %}*/};//多行注释为了引入其他html文件,实现多行文本对js变量的赋值
var lines=new String(nm.toString());
lines=lines.substring(lines.indexOf("/*") + 2, lines.lastIndexOf("*/"));
$(".rightpane").html(lines);
- Python输出不换行
#python 2
print x,
#python 3
print (x,end='')
- JavaScript中的数据类型判断
typeof obj=='object')&&obj.constructor==Object,Array,String,Function,Date,Number
注意object要加引号。
- <ul><li></li>...<li></li></ul>横着排列
ul li{float:left;}
- 查看Django版本
python -c "import django; print(django.get_verision())"
Execute the Python code in command. command can be one or more statements separated by newlines, with significant leading whitespace as in normal module code.
If this option is given, the first element of sys.argv will be "-c" and the current directory will be added to the start of sys.path (allowing modules in that directory to be imported as top level modules).
>>> dir(django)
['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'get_version']
- Django模板变量字符串连接
<span style="font-family: Arial, Helvetica, sans-serif;">{{"pre_"|add:name|add:"_post"}}</span>
- Python中字符串类型判断:isinstance(obj, basestring)
- Python中函数作为参数时的默认值
- Django的内置标签:with
For example:
{% with total=business.employees.count %}
{{ total }} employee{{ total|pluralize }}
{% endwith %}
The populated variable (in the example above, total) is only available between the {% with %} and {% endwith %} tags.
You can assign more than one context variable:
{% with alpha=1 beta=2 %}
...
{% endwith %}
Note
The previous more verbose format is still supported: {% with business.employees.count as total %}
- js中的键盘响应事件
$(document).keydown(function(evt) {
evt.which == 38 //左
evt.which == 39 //上
evt.which == 40 //右
evt.which == 41 //下
});
- select多选以及取值赋值
多选:<select multiple></select>
取值:val(),如果为多选结果为数组
赋值:val(values),如果为多选,values为数组
- js关联数组
js中的关联数组其实也是一对象
var arr=[];
arr['one']=1;
arr['two']=2;
console.log(arr.length); //0
var dct={};
dct['one']=1;
dct['two']=2;
console.log(dct.length); //undefined
- 动态加载js文件
$.ajax({
url: "{{STATIC_URL}}plugin/jsRender/jsviews.js",
async: false,
dataType: "script"
});
-
python判断变量是否为字符串
def chkstr(s):
try:s+''
except:return False
else:return True
- document中的innerHTML/outerHTML
- 注销hover事件
$(_this).unbind("mouseenter").unbind("mouseleave");
- 从Postgresql中随即选取100条记录
select * from heatmap order by random() limit 100
- 把数据从文件导入到Postgresql
copy heatmap from '/home/postgres/out.csv' delimiter '|';
- google chrome 不能以root用户运行解决
exec -a "$0" "$HERE/chrome" "$@
--user-data-dir"
- django的模板中没有!=,应该用not x == y来代替
- 隐藏input边框
<span style="font-weight: bold; white-space: pre;"> </span>input:focus{
outline: none;
}
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
- django模板遍历字典
{% for key,value in dicts.items %}
{% endfor %}