This file contains hidden or 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
| import datetime | |
| import time | |
| def convert_datetime_from_str(str): | |
| return datetime.datetime.fromtimestamp( | |
| time.mktime( | |
| time.strptime( | |
| str,"%Y-%m-%d %H:%M:%S"))) |
This file contains hidden or 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
| dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) else None | |
| json.dumps(data, default=dthandler) |
This file contains hidden or 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
| for k, v in sorted(d.items(), key=lambda x:x[1]): | |
| print k, v |
This file contains hidden or 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
| def convert_datetime_to_unixtime(d) | |
| time.mktime(d.timetuple()) |
This file contains hidden or 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
| re.sub(u'([ぁ-ゞァ-ヾ一-龠0−9!?]+)', lambda m: urllib2.quote(m.group(0).encode('utf8')), k) |
This file contains hidden or 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
| list.sort( cmp=lambda x, y: cmp(x, y), reverse=True ) |
This file contains hidden or 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
| list.sort(cmp=lambda x,y: cmp(int(x), int(y))) |
This file contains hidden or 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
| dir_names.sort(cmp=lambda x,y: cmp(os.path.getctime('%s/%s' % (base_dir, x)), os.path.getctime('%s/%s' % (base_dir, y))) |
This file contains hidden or 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
| aaa = {} | |
| isinstance(aaa, dict) |
This file contains hidden or 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
| function isNumber(str) { | |
| return !isNaN(+str) | |
| } |
OlderNewer