mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-08 07:46:46 +02:00
Fix a typo, plus section headings
This commit is contained in:
@@ -51,7 +51,7 @@ Note: This article applies to Python 3 specifically. Check out the other tutoria
|
|||||||
# 浮点数的运算结果也是浮点数
|
# 浮点数的运算结果也是浮点数
|
||||||
3 * 2.0 # => 6.0
|
3 * 2.0 # => 6.0
|
||||||
|
|
||||||
# Modulo operation
|
# 模除
|
||||||
7 % 3 # => 1
|
7 % 3 # => 1
|
||||||
|
|
||||||
# x的y次方
|
# x的y次方
|
||||||
@@ -72,7 +72,7 @@ not False # => True
|
|||||||
True and False #=> False
|
True and False #=> False
|
||||||
False or True #=> True
|
False or True #=> True
|
||||||
|
|
||||||
# 整数也可以是布尔值
|
# 整数也可以当作布尔值
|
||||||
0 and 2 #=> 0
|
0 and 2 #=> 0
|
||||||
-5 or 0 #=> -5
|
-5 or 0 #=> -5
|
||||||
0 == False #=> True
|
0 == False #=> True
|
||||||
@@ -101,10 +101,10 @@ False or True #=> True
|
|||||||
"这是个字符串"
|
"这是个字符串"
|
||||||
'这也是个字符串'
|
'这也是个字符串'
|
||||||
|
|
||||||
# 用加好连接字符串
|
# 用加号连接字符串
|
||||||
"Hello " + "world!" # => "Hello world!"
|
"Hello " + "world!" # => "Hello world!"
|
||||||
|
|
||||||
# A string can be treated like a list of characters
|
# 字符串可以被当作字符列表
|
||||||
"This is a string"[0] # => 'T'
|
"This is a string"[0] # => 'T'
|
||||||
|
|
||||||
# .format can be used to format strings, like this:
|
# .format can be used to format strings, like this:
|
||||||
@@ -139,7 +139,7 @@ bool({}) #=> False
|
|||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 2. Variables and Collections
|
## 2. 变量和集合
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
# Python has a print function
|
# Python has a print function
|
||||||
@@ -300,7 +300,7 @@ filled_set | other_set # => {1, 2, 3, 4, 5, 6}
|
|||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 3. Control Flow and Iterables
|
## 3. 流程控制和迭代器
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
# Let's just make a variable
|
# Let's just make a variable
|
||||||
@@ -398,7 +398,7 @@ list(filled_dict.keys()) #=> Returns ["one", "two", "three"]
|
|||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 4. Functions
|
## 4. 函数
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
# Use "def" to create new functions
|
# Use "def" to create new functions
|
||||||
@@ -490,7 +490,7 @@ filter(lambda x: x > 5, [3, 4, 5, 6, 7]) # => [6, 7]
|
|||||||
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7]
|
[x for x in [3, 4, 5, 6, 7] if x > 5] # => [6, 7]
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 5. Classes
|
## 5. 类
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
|
|
||||||
@@ -544,7 +544,7 @@ Human.grunt() # => "*grunt*"
|
|||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 6. Modules
|
## 6. 模块
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
# You can import modules
|
# You can import modules
|
||||||
@@ -575,7 +575,7 @@ dir(math)
|
|||||||
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 7. Advanced
|
## 7. 高级用法
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
# Generators help you make lazy code
|
# Generators help you make lazy code
|
||||||
|
Reference in New Issue
Block a user