摘要:
3.1. Using Python as a CalculatorLet’s try some simple Python commands. Start the interpreter and wait for the primary prompt, >>>. (It shouldn’t take... 阅读全文
摘要:
8.1. Syntax ErrorsSyntax errors, also known as parsing errors, are perhaps the most common kind of complaint you get while you are still learning Pyth... 阅读全文
摘要:
There are several ways to present the output of a program; data can be printed in a human-readable form, or written to a file for future use. This cha... 阅读全文
摘要:
6. ModulesIf you quit from the Python interpreter and enter it again, the definitions you have made (functions and variables) are lost. Therefore, if ... 阅读全文
摘要:
5.2. The del statementThere is a way to remove an item from a list given its index instead of its value: the del statement. This differs from the pop(... 阅读全文
摘要:
5. Data StructuresThis chapter describes some things you’ve learned about already in more detail, and adds some new things as well.这一章节将更详细的描述你已经学到的东西... 阅读全文
摘要:
4.6. Defining FunctionsWe can create a function that writes the Fibonacci series to an arbitrary boundary:我们创建一个斐波那契数列的函数:>>> def fib(n): # write F... 阅读全文
摘要:
4.1. if StatementsPerhaps the most well-known statement type is the if statement. For example:if语句可能是最常见的控制流语句了,例如:>>> x = int(input("Please enter an ... 阅读全文
摘要:
3.1.3. ListsPython knows a number of compound data types, used to group together other values. The most versatile is the list, which can be written as... 阅读全文