巧妙使用引号 将Shell和Python杂交(为python代码选择解析器)

前面shell的作用就是为python代码选择解析器

#!/bin/bash
# -*- mode: Python -*-

""":"
# bash code here; finds a suitable python interpreter and execs this file.
# prefer unqualified "python" if suitable:
python -c 'import sys; sys.exit(not (0x020500b0 < sys.hexversion /dev/null 
    && exec python "$0" "$@"

for pyver in 2.6 2.7 2.5; do
    which python$pyver > /dev/null 2>&1 && exec python$pyver "$0" "$@"
done

echo "No appropriate python interpreter found." >&2
exit 1
":"""

print 'Hello from python code'