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
| #!/bin/bash | |
| . ~/.bash_profile | |
| . ~/virtualenv/bin/activate | |
| dt=`date +'%Y-%m-%d'` | |
| day=`date +'%Y%m%d'` | |
| cd virtualenv/report | |
| python main.py --table 催收DL $dt |
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
| class Person(object): | |
| __slots__ = ('name', 'gender') | |
| def __init__(self, name, gender): | |
| self.name = name | |
| self.gender = gender | |
| class Student(Person): |
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 heapq | |
| dicts = [ | |
| {'name':'cbb','price':1221}, | |
| {'name':'bbc','price':212}, | |
| {'name':'cbc','price':12}, | |
| {'name':'bcb','price':112} | |
| ] | |
| print(heapq.nlargest(2, dicts, key=lambda s:s['price'])) | |
| print(heapq.nsmallest(2, dicts, key=lambda s:s['price'])) |
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
| #!/usr/bin/python | |
| # Filename: using_name.py | |
| if __name__ == '__main__': | |
| print 'This program is being run by itself' | |
| else: | |
| print 'I am being imported from another module' | |
| # ------------output----------------- | |
| $ python using_name.py |
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
| #!/usr/bin/python3 | |
| #coding=utf-8 | |
| #save file : bitwise_operators_example.py | |
| a = 60 # 60 = 0011 1100 | |
| b = 13 # 13 = 0000 1101 | |
| print ('a=',a,':',bin(a),'b=',b,':',bin(b)) | |
| c = 0 |
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
| mkdir test 创建放置文件的比对文件夹 | |
| git init 生成git本地仓库 | |
| touch a1.py 创建a1文件 | |
| git add 加入跟踪 | |
| git commit -m "a1" 提交至版本 | |
| 删除a1.py中的代码,贴入新的代码 | |
| git add .跟踪文件 | |
| git commit -m "a2" 提交新版本 | |
| git log 查看commit id信息 | |
| git diff commit_id1 commit_id2 -- a.py 笔记两次提交的内容的变化 |
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
| setting.py | |
| DEBUG = True # 通过这种方式可以打开 DEBUG 模式 | |
| LOGGING = { | |
| 'version': 1, | |
| 'disable_existing_loggers': False, | |
| 'filters': { | |
| 'require_debug_true': { | |
| '()': 'django.utils.log.RequireDebugTrue', | |
| }, # 针对 DEBUG = 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
| # 作者:xianhu | |
| # 链接:https: // zhuanlan.zhihu.com / p / 22909144 | |
| '''类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算----类型和运算''' | |
| # -- 寻求帮助: | |
| dir(obj) # 简单的列出对象obj所包含的方法名称,返回一个字符串列表 | |
| help(obj.func) # 查询obj.func的具体介绍和用法 | |
| # -- 测试类型的三种方法,推荐第三种 |
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
| request.FILES['filename'].name | |
| If you don't know the key, you can iterate over the files: | |
| for filename, file in request.FILES.iteritems(): | |
| name = request.FILES[filename].name |
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
| cur.execute( ... """INSERT INTO some_table (an_int, a_date, another_date, a_string) ... | |
| VALUES (%(int)s, %(date)s, %(date)s, %(str)s);""", ... | |
| {'int': 10, 'str': "O'Reilly", 'date': datetime.date(2005, 11, 18)}) |