`

Python学习笔记(一): Build envrionment

阅读更多
1. python官网:http://www.python.org/
2. Set environment variables for Python
   2.1 首先需要在系统中注册python环境变量:假设python的安装路径为c:\python2.6,则修改我的电脑->属性->高级->环境变量->系统变量中的PATH为:

PATH=PATH;D:\Tools\Python33
上述环境变量设置成功之后,就可以在命令行直接使用python命令。或执行"python *.py"运行python脚本了。



   2.2 此时,还是只能通过"python *.py"运行python脚本,若希望直接运行*.py,只需再修改另一个环境变量PATHEXT:

PATHEXT=PATHEXT;.PY;.PYM

   2.4 如何使Python解释器能直接import默认安装路径以外的第三方模块?

为了能import默认安装路径以外的第三方的模块(如自己写的模块),需要新建PYTHONPATH环境变量,值为这个模块所在的目录。

3. Python help:

H:\>python
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help('print')
Help on built-in function print in module builtins:

print(...)
    print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)

    Prints the values to a stream, or to sys.stdout by default.
    Optional keyword arguments:
    file:  a file-like object (stream); defaults to the current sys.stdout.
    sep:   string inserted between values, default a space.
    end:   string appended after the last value, default a newline.
    flush: whether to forcibly flush the stream.

>>> help('hh');
no Python documentation found for 'hh'

>>> help('hh')
no Python documentation found for 'hh'

4. Exit Python

如何退出Python提示符
如果你使用的是Linux/BSD shell,那么按Ctrl-d退出提示符。如果是在Windows命令行中,则按Ctrl-z再按Enter。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics