Python - 开始使用Python编程

来源:互联网 发布:java中时间格式化 编辑:程序博客网 时间:2024/05/01 01:46

Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs.

在我使用Ubuntu做为我的操作系统以来,根据我的体会上面说的没错。功能强大,简单灵活的脚本语言。即使你使用windows搭建Python的运行环境也很简单。

Python官方网站: http://www.python.org/


我使用Ubuntu 12.04 LTS,Python包是默认安装的。如果你使用Windows,要去官网上下载Windows的Installer,之后将包含python.exe的安装目录加入系统环境变量Path中,你就可以使用python命令了,脚本的执行要依赖这个python.exe。


如何运行Python脚本?

Python脚本是以.py结尾的文件,在Linux系统下有两种执行方式

假设你有脚本hello.py,

./hello.py
或者

python hello.py


如何查看我的python版本?

python --version

如何知道python指令安装在什么位置?

which python

第一个python脚本hello.py


#!/usr/bin/pythonprint 'Hello, world!'

保存文件,赋给它可执行权限,执行
python hello.py