摘要:
type in msconfig to start System Configuration tool Switch to Tools Tab, and choose Change UAC Settings And finally modify settings by choosing Never 阅读全文
摘要:
getattr class ObjectDict(dict): def __init__(self, *args, **kwargs): super(ObjectDict, self).__init__(*args, **kwargs) def __getattr__(self, name): va 阅读全文
摘要:
需要将list以字符串的形式输出,但是list中有不是字符串的情况 ls1 = [1,'ab','cd'] ls2 = [str(i) for i in ls1] # 方法1 ls3 = map(lambda i:str(i), ls1) # 方法2 str_1 = ''.join(ls2) str 阅读全文
摘要:
robot中比较难理解的【元类和描述符类】 【重点1】with_metaclass,init,new 【重点2】get,set with_metaclass见如下文章: https://stackoverflow.com/questions/18513821/python-metaclass-und 阅读全文
摘要:
基础 class C(object): @staticmethod def f(): print('runoob'); C.f(); # 静态方法无需实例化 cobj = C() cobj.f() # 也可以实例化后调用 进阶【staticmethod 参数要求是 Callable, 也就是说 Cl 阅读全文
摘要:
bool,len__和bool相关,在if中会被调用,优先调用__bool,没有就调用__len__ class Test: def __bool__(self): print('__bool__') return False def __len__(self): print('__len__') 阅读全文
摘要:
import os import sys JYTHON = sys.platform.startswith('java') IRONPYTHON = sys.platform == 'cli' PYPY = 'PyPy' in sys.version PYTHON = not (JYTHON or 阅读全文
摘要:
使用next() def foo(): print("starting...") while True: res = yield 4 # yield 在等式的右边,执行完就返回了,没有进行赋值 ;类似于 a = return 1【return这样用非法】,a 是NONE print("res:",r 阅读全文
摘要:
sys.exc_info() 获取异常 import sys try: raise ValueError('this is a exp') except Exception as ex: ex_type, ex_val, ex_stack = sys.exc_info() print(ex_type 阅读全文
摘要:
def _split_camel_case(string): tokens = [] token = [] for prev, char, next in zip(' ' + string, string, string[1:] + ' '): print(prev, char, next) if 阅读全文