#define MAX(a, b) (a) > (b) ? (a) : (b);
void f() {
int a(1), b(0);
MAX(++a, b); // a 被累加两次
MAX(++a, b+10); // a 被累加1次
}
注意:本系列文章均以linux为主 实际操作之前,请确保已经安装Python并且将python添加到环境变量
python
linadeMacBook-Pro:Downloads lina$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> hi = "hello world"
>>> print(hi)
hello world
>>>
python <python-script-name>.py
创建一个以py结尾的文件,输入下面的内容,保存为hello.py, 它就成为了一个python脚本 #hello.py
hi = "hello world"
print(hi)
保存之后,在终端敲入:
linadeMacBook-Pro:Downloads lina$ python hello.py
hello world
linadeMacBook-Pro:Downloads lina$
这样脚本就执行完成了
#!/usr/bin/env python
hi = "hello world"
print(hi)
添加可执行权限:
linadeMacBook-Pro:Downloads lina$ chmod +x hello.py
linadeMacBook-Pro:Downloads lina$ ./hello.py
hello world
linadeMacBook-Pro:Downloads lina$
>`#!/usr/bin/env python`的意思是到环境变量中查找python解释器的路径,这种写法比`#!/usr/local/bin/python`的写法更有可移植性