本文介绍了运算符重载的概念,列出了一些常用的运算符重载方法,并详细介绍了索引和分片:__getitem__和__setitem__、迭代器对象:__iter__和__next__、成员关系:__contains__、__iter__和__getitem__这些运算符重载方法...
分类:
编程语言 时间:
2016-02-24 09:50:39
阅读次数:
261
sessionStorage/localStorage1.保存方法setItem(key,value)2.读取方法getItem(key)3.遍历方法 sessionStorage.length sessionStorage.key(i)4.删除方法:sessionStorage.rem...
分类:
Web程序 时间:
2016-01-18 18:46:51
阅读次数:
151
// Save datavar storage = require('node-persist');storage.init();var people= require('./people.json');people.forEach( (person)=>{ storage.setItem(per....
分类:
Web程序 时间:
2015-12-26 18:48:02
阅读次数:
201
目前我知道的有两种方法:1 定义的类继承dict类例如class A(dict): passa = A()a['name'] = 122 给自定义的类添加__setitem__() __getitem__()方法class A: def __init__(self, cfg={}): self.c....
分类:
编程语言 时间:
2015-12-17 19:10:33
阅读次数:
134
把一个全局变量存到localStorage里面 isSupport是 true false;window.localStorage && window.localStorage.setItem("webpsupport", isSupport);var isSupport=window.loc...
分类:
其他好文 时间:
2015-12-01 14:32:49
阅读次数:
268
1、说明:__getitem__\setitem可以迭代,它已经不被推荐了;建议使用__iter__\next。2、python会先去检查__iter__\next然后再去检查__getitem__\__setitem__,也就是说__iter__优先。例子:#!coding:utf-8#!pyth...
分类:
编程语言 时间:
2015-11-12 20:10:58
阅读次数:
300
1、想要自己定义的python对象支持索引与分片操作就要重载__getitem__\__setitem__这两个方法。2、__getitme__(self,index) 这里的index参数可能类型有两种int,slice。当它是int类型时对应索引操作,当它是slice时对应分片操作。3、__s....
分类:
编程语言 时间:
2015-11-12 20:07:49
阅读次数:
593
1.获取localStorage的长度:window.localStorage.length;2.添加/编辑localStorage的内容:window.localStorage.setItem(键,值);3.根据对应的索引去获取对应localStorage的key的值:window.localSt...
分类:
Web程序 时间:
2015-10-08 16:15:42
阅读次数:
129
在HTML5中可以把数据长期存储在客户端,使用的对象就是localStorage。localStorage常用方法有setItem、getItem、removeItem、clear。下面是一个存储数组对象的例子,由于localStorage中存储的数据会自动转换为字符串,数组类型则会自动join("...
分类:
其他好文 时间:
2015-09-12 12:05:12
阅读次数:
117
// sessionStorage.setItem("message",str);function saveStorage(id){ var target = document.getElementById(id); var str = target.value; //保存数据的方...
分类:
Web程序 时间:
2015-08-30 15:49:31
阅读次数:
126