Web Scraping爬虫 for Mac urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)> Solution:  if 1) does not work, then try to use 2).  Reference is here. 1) pip install --upgrade certifi 2) open /A…
Get the file name from the file path Solution: var fileName = fullPath.replace(/^.*[\\\/]/, ''); // This will handle both \ or / in paths.…
Stick button in right side in html Solution: //In the html <div class="float__button" > </div> // In the css file .float__button{ margin-right: 5%; float: right; } Set the size of textarea in CSS. Solution: //In the html <div clas…
模板: Split string into parts based on new line in java Solution:   Reference is here. 1) get out of the first part of a string until meet "<" Solution:   Reference is public String[] split(String regex). 1)  s = "boo:and:foo";     St…
先上结论: 函数(function)是Python中一个可调用对象(callable), 方法(method)是一种特殊的函数. 一个可调用对象是方法和函数,和这个对象无关,仅和这个对象是否与类或实例绑定有关(bound method). 实例方法,在类中未和类绑定,是函数:在实例中,此实例方法与实例绑定,即变成方法. 静态方法没有和任何类或实例绑定,所以静态方法是个函数. 装饰器不会改变被装饰函数或方法的类型. 类实现__call__方法,其实例也不会变成方法或函数,依旧是类的实例. 使用ca…
Python的method可以设置默认参数, 默认参数如果是可变的类型, 比如list, map等, 将会影响所有的该方法调用. 下面是一个简单的例子 def f(a=None, l=[]): if not a: return l l.append(a) return l if __name__ == "__main__": print f("a") print f("b") print f("b") print f(l=[]…
1.什么是函数 它是一段功能代码,理解为一种功能行为,在内存中有空间区域,函数需要被调用才能执行(通过函数名来调用): 好处: 1).提高代码的复用性 2).提升代码的阅读性 3).增加代码的扩展性 4).增强了代码的维护性 2.函数有五要素组成 ①.函数修饰符                    关键字def开头 ②.函数返回值类型             有返回值(类型:int.float.str.list...)/没有返回值 ③.函数名                          …
Description The method strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string (default whitespace characters). 在string中删掉strip(char)的所有char字符. Syntax str.strip([chars]) Parameters chars…
# The get() method on dicts # and its "default" argument name_for_userid = { 382: "Alice", 590: "Bob", 951: "Dilbert", } def greeting(userid): return "Hi %s!" % name_for_userid.get(userid, "there"…
一,摘自官方API  https://docs.python.org/3/library/stdtypes.html#methods str.startswith(prefix[, start[, end]]) Return True if string starts with the prefix, otherwise return False. prefix can also be a tuple of prefixes to look for. With optional start, t…