What do the three arrow (“>>>”) signs mean?

前端 未结 4 1821
小蘑菇
小蘑菇 2020-12-05 17:06

So this is probably a dumb question, but I have now been searching for quite some time, and I haven\'t been able to figure out what they do even though I see them often in s

4条回答
  •  清歌不尽
    2020-12-05 17:49

    '>>>' is the prompt of the interactive Python interpreter, meaning that the interpreter is ready to get Python statements typed in. It's occuring quite often in examples within the documentation of a Python program, in order to show which commands can be used and what will be the result of giving these commands to the interactive interpreter. For example, in a documentation of the print statement, one could give this example:

    >>> print "Hello world."
    Hello world.
    

    This would be an actual snippet of a session with the interactive Python interpreter.

    An interesting feature in IPython is that it ignores leading >>>, meaning that you can copy and paste code from such documentation without needing to remove the leading >>>:

    In [1]: >>> print "Hello world."
    Hello world.
    

    (The prompt in IPython is In [n]:, where n is counting the interactive commands issued.)

提交回复
热议问题