If not os.path.esists(key_word): os.mkdir(key_word)
Confirm that the path exists; when crawling data classification save the downloaded file
function
Function is a separate tool does not reduce the amount of codes
The syntax of the function
def function name; definitions Tool Name - "and the same variable specification ," to achieve the function " function name () before use; (encapsulate internal code by function name def +)
DEF name (): normal writer name () # use the function
-
Empty function;
#TODO: Registration is temporarily not write # to insert a bookmark,
Pass # write an empty function accounting positions -
parameter;
Type reference (description) argument (specific values)
DEF the Add ( X, Y): # X, Y-type reference return X + Y the Add ( . 1, 2) # 1,2 argument
-
The default type parameters;
Had been paid value in the definition stage, you can not pay the value at the time of call, it can pay its value to the default value replaced.
-
Keyword argument;
When calling the function, value pairs in the manner specified through the parameter values, can break position regulating
You can mix solid position to participate in the keyword argument, but the argument must be key position after the argument, and can not pay duplicate reference value for a type.
-
Location parameters;
From left to right a defined type parameters, each value must be delivered, the location argument must correspond therewith.
-
Return value of the function; return
After some internal code function result obtained by the processing logic. Need to be, but does not print the result
return function is a sign of the end
return return value can be any data type
-
No reference function;
No argument, no input parameters used directly
DEF the Add (): Print ( 'fixed content') the Add ()
-
There are function parameters
There are parameters, you must use the input parameters
defadd(x,y):
returnx+y
add(1,2)