参考内容 Dive into python
参考内容 Runoob 教程
0. Installing python
1. Function
1.1 First python program
1 | SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'], |
function format:
1 | def func_name(var1, var2 = v2, *args, **kargs) |
Note:
- Use
''' '''to include instruction of functions, which is shown infun.__doc__- The
fun.__name__is__main__Only when the program is being executed, it will not be executed when be imported- Python use tab to promise a block, not
endor{}*argslikes a tuple, passing par values**kargslikes a dic, passing key values and namesfunc.__self__
Everything is object:
Use type() or .type to view the class of variable.
- SUFFIXES: dictionary
- SUFFIXES[index]: list
- approximate_size: function
- print: built-in function
Variables:
1 | >>> from humansize import approximate_size |
As soon as you have a named argument, all arguments to the right of that need to be named arguments, too.