第二章、Python脚本运行
1.Python脚本
用文本编辑器写一个以 .py 结尾的文件,Python程序写在文件里面,如:hello.py 这就是脚本。
#!/usr/bin/env python 引导程序找到python编辑器 #coding:utf-8 编码方式 print('a')
运行脚本前需要给 .py 文件一个可执行权限
chmod a+x hello.py
或者
chmod 755 hello.py
运行脚本方式:当前工作路径需和脚本文件所在路径一致,或者需要输出完整的脚本文件路径
(1)命令:# python 文件名.py
# python hello.py
( 2)命令:# ./文件名.py
# ./hello.py

浙公网安备 33010602011771号