Common methods for modules and modules
Critical: __init__.py
Whether to master file: __name__ if__name== ' __main__ '
Current file path: __file__
Current File Description: __doc__
" " Created May 4,2017@author:eilleen " " Print __name__ Print __file__ Print __doc__
function type
Parametric def Fun (Arg,*args,**kargs):
#!usr/bin/env python#Coding:utf-8defFoo (name):" "order the old dog" " PrintName'old dog to chop wood'Foo ('xwx') Foo ('VFDBFGN') Foo ('Wret') Foo ('acssfdnhg')
#!usr/bin/env python#Coding:utf-8#From __main__ import name#Import __main__defLogin (username):ifusername=='Alex': Print 'Login Successful' returnTrueElse: Print 'Logon Failure' returnFalsedefDetail (user):Print '&&&&&&&&&&&&&&&&&&7' if __name__=='__main__': User=raw_input ('Please enter') ifLogin (user): Detail (user)Else: Print'xxxxxxxxxxxxxxxxxxxxxxx'Default parameter variable parameter
defFoo (name,where='Beijing', action='Chopping wood'): PrintName'go to', where,action foo ('AA','Shanghai','Eat')#AA to Shanghai for dinnerFoo'mm','Eat','Shanghai')#mm go to dinner ShanghaiFoo'DD', action='Chopping wood', where='342')#DD go to 342 chopping woodFoo'RR','See')#RR go see firewood
python-module and function (i)