（首页）开始编程之旅 翻译自Lee Harr的Start Programming

# 1. StartProgramming-1-8 帮助Help

We will come back to functions and sequences in the next chapter, but first I want to bring up one more thing about the interactive interpreter:

Notice that by typing:

`help`

python will tell you how to get help.

python将会告诉你怎样获得帮助。

Basically, it tells you to type help() with which you can enter the python help browser and get a lot of generally helpful information. Alternatively, you can put something inside the parentheses which you want to get help on. Try this:

```>>> help(range)
Help on built-in function range:

range(...)
range([start,] stop[, step]) -> list of integers

Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!) defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3]. The end point is omitted!
These are exactly the valid indices for a list of 4 elements.```

You type in the first line, after the >>>

`help(range)`

and Python will tell you about the range function.

Python就会告诉你关于range函数的帮助。

That is interesting. Let's try out the example they give:

```range(4)
returns: [0, 1, 2, 3]```

Just like they said it would be. How about if we give range 2 numbers:

```range(4, 10)
returns: [4, 5, 6, 7, 8, 9]```

Notice how the list returned does include the first number you give, but it does not include the last number you give.

Now try range with 3 arguments:

```range(0, 100, 10)
returns: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]```

Very nice. I wonder if we can use this to make pete perform some even more amazing tricks?

Also notice that you can get help on pete himself!

Unfortunately, help(pete) only tells us that pete is an instance of the Penguin class. We can get help on pete and all of his kind with:

`help(Penguin)`

StartProgramming-1-8 (last edited 2009-12-25 07:13:54 by localhost)