【A ByteOf Python2.7】第2章 安装Python

Linux和BSD用户

如果你正在使用一个Linux的发行版比如Fedora或者Mandrake或者其他(你的选择),或者一个BSD系统比如FreeBSD,那么你可能已经在你的系统里安装了Python。
要测试你是否已经随着你的Linux包安装了Python,你可以打开一个shell程序(就像konsole或gnome-terminal)然后输入如下所示的命令 python -V
$ python -V
Python 2.3.4
注释
$ 是shell的提示符。根据你的操作系统的设置,它可能与你那个不同,因此我只用 $ 符号表示提示符。
如果你看见向上面所示的那样一些版本信息,那么你已经安装了Python了。
如果你得到像这样的消息:
$ python -V
bash: python: command not found
那么你还没有安装Python。这几乎不可能,只是极其偶尔才会遇到。
在这种情况下,你有两种方法在你的系统上安装Python。
  • 利用你的操作系统附带的包管理软件安装二进制包,比如Fedora Linux的yum、Mandrake Linux的urpmi、Debian Linux的apt-get、FreeBSD的pkg_add等等。注意,使用这种方法的话,你需要连接因特网。
    你也可以从别的地方下载二进制包然后拷贝到你的PC中安装。
  • 你可以从源代码编译Python然后安装。在网站上有编译的指令。

Windows®用户

Windows®用户可以访问 Python.org/download ,从网站上下载最新的版本(在写本书的时候,最新版本是 2.3.4 版)。它的大小大约是9.4MB,与其他大多数语言相比是十分紧凑的。安装过程与其他Windows软件类似。
提示
即便安装程序为你提供了不检查   可选   组件的选项,你也不要不作任何检查!有些组件对你很有用,特别是集成开发环境。
有趣的是,大约70%的Python下载是来自Windows用户的。当然,这并不能说明问题,因为几乎所有的Linux用户已经在安装系统的时候默认安装了Python。
在Windows命令行中使用Python
如果你想要从Windows命令行调用Python,那么你需要先正确的设置PATH变量。
对于Windows 2000、XP、2003,点击控制面板->系统->高级->环境变量。在“系统变量”表单中点击叫做 PATH 的变量,然后编辑这个变量,把 ;C:\Python23 加到它的结尾。当然,是Python所在的正确目录名。
对于较旧版本的Windows,把下面这行加到文件C:\AUTOEXEC.BAT中: PATH=%PATH%;C:\Python23 ,然后重新启动系统。对于Windows NT,则使用AUTOEXEC.NT文件。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
this is a book about python. it was written by Swaroop C H.its name is "a byte of python". Table of Contents Preface Who This Book Is For History Lesson Status of the book Official Website License Terms Using the interpreter prompt Choosing an Editor Using a Source File Output How It Works Executable Python programs Getting Help Summary 4. The Basics Literal Constants Numbers Strings Variables Identifier Naming Data Types Objects Output How It Works Logical and Physical Lines Indentation Summary 5. Operators and Expressions Introduction Operators Operator Precedence Order of Evaluation Associativity Expressions Using Expressions Summary 6. Control Flow Introduction The if statement ivUsing the if statement How It Works The while statement Using the while statement The for loop Using the for statement Using the break statement The continue statement Using the continue statement Summary 7. Functions Introduction Defining a Function Function Parameters Using Function Parameters Local Variables Using Local Variables Using the global statement Default Argument Values Using Default Argument Values Keyword Arguments Using Keyword Arguments The return statement Using the literal statement DocStrings Using DocStrings Summary 8. Modules Introduction Using the sys module Byte-compiled .pyc files The from..import statement A module's __name__ Using a module's __name__ Making your own Modules Creating your own Modules from..import The dir() function Using the dir function Summary 9. Data Structures Introduction List Quick introduction to Objects and Classes Using Lists Tuple Using Tuples Tuples and the print statement Dictionary Using Dictionaries Sequences Using Sequences References Objects and References More about Strings String Methods Summary 10. Problem Solving - Writing a Python Script The Problem The Solution First Version Second Version Third Version Fourth Version More Refinements The Software Development Process Summary 11. Object-Oriented Programming Introduction The self Classes Creating a Class object Methods Using Object Methds The __init__ method Using the __init__ method Class and Object Variables Using Class and Object Variables Inheritance Using Inheritance Summary 12. Input/Output Files Using file Pickle Pickling and Unpickling Summary 13. Exceptions Errors Try..Except Handling Exceptions Raising Exceptions How To Raise Exceptions Try..Finally Using Finally Summary 14. The Python Standard Library Introduction The sys module Command Line Arguments More sys The os module Summary 15. More Python Special Methods Single Statement Blocks List Comprehension Using List Comprehensions Receiving Tuples and Lists in Functions Lambda Forms Using Lambda Forms The exec and eval statements The assert statement The repr function Summary 16. What Next? Graphical Software Summary of GUI Tools Explore More Summary A. Free/Libré and Open Source Software (FLOSS) B. About Colophon About the Author C. Revision History Timestamp

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值