Python installation
Windows
| 1234567 |
1、下载安装包 https://www.python.org/downloads/2、安装 默认安装路径:C:\python273、配置环境变量 【右键计算机】--》【属性】--》【高级系统设置】--》【高级】--》【环境变量】--》【在第二个内容框中找到 变量名为Path 的一行,双击】 --> 【Python安装目录追加到变值值中,用 ; 分割】 如:原来的值;C:\python27,切记前面有分号 |
Linux, Mac
| 123 |
无需安装,原装Python环境 ps:如果自带2.6,请更新至2.7 |
V. Hello World Program
Create a file under Linux called hello.py, and enter
Then execute the command: Python hello.py, output
| 123 |
localhost:~ lei$ vim hello.pylocalhost:~ lei$ python hello.pyHello World! |
Specify interpreter
When executing Python hello.py in the previous step, it is clear that the hello.py script is executed by the Python interpreter.
If you want to execute a python script like executing a shell script, for example, you ./hello.py would need to specify the interpreter at the head of the hello.py file, as follows:
| 123 |
#!/usr/bin/env python print"hello,world" |
So, execute:. /hello.py Can.
PS: Need to give hello.py execute permission before execution, chmod 755 hello.py
Executing in the interactive device
In addition to writing the program in the file, you can also call the Python's own interactive running code,
| 123456 |
localhost:~ lei$ pythonPython 2.7.10(default, Oct232015, 18:05:06)[GCC 4.2.1Compatible Apple LLVM 7.0.0(clang-700.0.59.5)] on darwinType"help", "copyright", "credits"or"license" formore information.>>> print("Hello World!")Hello World! |
Python Learning notes----01, Python Installation