book read

Python is a dynamic, interpreted (bytecode-compiled) language. There are no type declarations of variables, parameters, functions, or methods in source code.

A Python program is just a text file that you edit directly.

Python is case sensitive so “a” and “A” are different variables.
The end of a line marks the end of a statement.
Comments begin with a ‘#’ and extend to the end of the line.
Blocks of code are delimited strictly using indentation rather than curly braces.
Python source files use the “.py” extension and are called “modules.”

A Python module can be run directly, or it can be imported and used by some other module.
When a Python file is run directly, the special variable “name” is set to “main“. Therefore, it’s common to have the boilerplate if name ==… when the module is run directly, but not when the module is imported by some other module.

#!/usr/bin/env python

# import modules used here -- sys is a very standard one
import sys

# Gather our code in a main() function
def main():
    print 'Hello there', sys.argv[1]
    # Command line args are in sys.argv[1], sys.argv[2] ...
    # sys.argv[0] is the script name itself and can be ignored

# Standard boilerplate to call the main() function to begin
# the program.
if __name__ == '__main__':
    main()

The docstring can be a single line, or a multi-line description, those are “triple quotes”.

def 函数名(参数列表):
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值