返回首页 简明 Python 教程

表格

例子

使用带提示符的 Python 解释器


    $ python
    Python 2.3.4 (#1, Oct 26 2004, 16:42:40)
    [GCC 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print 'hello world'
    hello world
    >>>

注意,Python 会在下一行立即给出你输出!你刚才键入的是一句 Python 语句 。我们使用 print(不要惊讶)来打印你提供给它的值。这里,我们提供的是文本 Hello World,它被迅速地打印在屏幕上。

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

上一篇: 一些特殊的方法 下一篇: 使用源文件