提交 f74e8860 编写于 作者: W wizardforcel

2020-07-10 21:38:09

上级 7cacb814
......@@ -167,7 +167,7 @@ global x: 5
非局部变量用于未定义局部范围的嵌套函数中。 这意味着该变量不能位于本地范围或全局范围内。
Let's see an example of how a global variable is created in Python.
让我们来看一个如何在 Python 中创建全局变量的示例。
我们使用`nonlocal`关键字创建非局部变量。
......
......@@ -168,7 +168,7 @@ print('str1 + str2 = ', str1 + str2)
print('str1 * 3 =', str1 * 3)
```
When we run the above program, we get the following output:
当我们运行程序时,我们得到以下输出:
```py
str1 + str2 = HelloWorld!
......@@ -206,7 +206,7 @@ for letter in 'Hello World':
print(count,'letters found')
```
When we run the above program, we get the following output:
当我们运行程序时,我们得到以下输出:
```py
3 letters found
......@@ -246,7 +246,7 @@ print('list(enumerate(str) = ', list_enumerate)
print('len(str) = ', len(str))
```
When we run the above program, we get the following output:
当我们运行程序时,我们得到以下输出:
```py
list(enumerate(str) = [(0, 'c'), (1, 'o'), (2, 'l'), (3, 'd')]
......@@ -285,7 +285,7 @@ print('He said, "What\'s there?"')
print("He said, \"What's there?\"")
```
When we run the above program, we get the following output:
当我们运行程序时,我们得到以下输出:
```py
He said, "What's there?"
......@@ -366,7 +366,7 @@ print('\n--- Keyword Order ---')
print(keyword_order)
```
When we run the above program, we get the following output:
当我们运行程序时,我们得到以下输出:
```py
--- Default Order ---
......
......@@ -317,7 +317,7 @@ print(A & B)
{4, 5}
```
Try the following examples on Python shell.
在 Python Shell 中尝试以下程序:
```py
# use intersection function on A
......@@ -360,7 +360,7 @@ print(A - B)
{1, 2, 3}
```
Try the following examples on Python shell.
在 Python Shell 中尝试以下程序:
```py
# use difference function on A
......@@ -407,7 +407,7 @@ print(A ^ B)
{1, 2, 3, 6, 7, 8}
```
Try the following examples on Python shell.
在 Python Shell 中尝试以下程序:
```py
# use symmetric_difference function on A
......
......@@ -117,7 +117,7 @@ repeat {
} while (i <= 5)
```
The output of the program is same as the above program.
程序输出与上一程序相同。
* * *
......@@ -141,7 +141,7 @@ while i <= 5 {
}
```
The output of the program is same as the above program.
程序输出与上一程序相同。
* * *
......
......@@ -102,7 +102,7 @@ for j in 1...2 {
}
```
When you run the program,the output will be:
当你运行程序时,输出为:
```swift
i = 1
......
......@@ -100,7 +100,7 @@ for j in 1...2 {
}
```
When you run the program,the output will be:
当你运行程序时,输出为:
```swift
i = 1
......
......@@ -91,7 +91,7 @@ let someValue:Int = 12
* **条件编译块**
A conditional compilation block allows code to be only compiled depending on the value of one or more compilation conditions. Every conditional compilation block begins with the `#if` and ends with `#endif`. A simple conditional compilation block has the following form:
条件编译块允许仅根据一个或多个编译条件的值来编译代码。 每个条件编译块均以`#if`开始,以`#endif`结尾。 一个简单的条件编译块具有以下形式:
```swift
#if compilation condition
......@@ -110,7 +110,7 @@ let someValue:Int = 12
#endif
```
The condition `swift(>=4.0)` is applied at the statement `#if #endif` . As a result, the `print` statement is executed only if swift version is greater than or equal to 4.0 at compile time.
条件`swift(>=4.0`应用于语句`#if#endif`。 结果,仅在编译时 swift 版本大于或等于 4.0 时才执行`print`语句。
* **行控制语句**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册