File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -53,15 +53,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit
53
53
下载Python源代码并解压缩到指定目录。
54
54
55
55
``` Shell
56
- wget https://www.python.org/ftp/python/3.7.0 /Python-3.7.1.tar.xz
57
- xz -d Python-3.7.1 .tar.xz
58
- tar -xvf Python-3.7.1 .tar
56
+ wget https://www.python.org/ftp/python/3.7.3 /Python-3.7.3.tgz
57
+ xz -d Python-3.7.3 .tar.xz
58
+ tar -xvf Python-3.7.3 .tar
59
59
```
60
60
61
61
切换至Python源代码目录并执行下面的命令进行配置和安装。
62
62
63
63
``` Shell
64
- cd Python-3.7.1
64
+ cd Python-3.7.3
65
65
./configure --prefix=/usr/local/python37 --enable-optimizations
66
66
make && make install
67
67
```
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ class Clock(object):
157
157
if self ._hour == 24 :
158
158
self ._hour = 0
159
159
160
- def __str__ (self ):
160
+ def show (self ):
161
161
""" 显示时间"""
162
162
return ' %02d :%02d :%02d ' % \
163
163
(self ._hour, self ._minute, self ._second)
@@ -166,7 +166,7 @@ class Clock(object):
166
166
def main():
167
167
clock = Clock(23 , 59 , 58 )
168
168
while True :
169
- print (clock)
169
+ print (clock.show() )
170
170
sleep(1 )
171
171
clock.run()
172
172
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ if __name__ == '__main__':
103
103
main()
104
104
```
105
105
106
- 要将文本信息写入文件文件也非常简单,在使用` open ` 函数时指定好文件名并将文件模式设置为` 'w' ` 即可。注意如果需要对文件内容进行追加式写入,应该将模式设置为` 'a' ` 。如果要写入的文件不存在会自动创建文件而不是引发异常。下面的例子演示了如何将1~ 9999直接的素数分别写入三个文件中(1~ 99之间的素数保存在a.txt中,100~ 999之间的素数保存在b.txt中,1000~ 9999之间的素数保存在c.txt中)。
106
+ 要将文本信息写入文件文件也非常简单,在使用` open ` 函数时指定好文件名并将文件模式设置为` 'w' ` 即可。注意如果需要对文件内容进行追加式写入,应该将模式设置为` 'a' ` 。如果要写入的文件不存在会自动创建文件而不是引发异常。下面的例子演示了如何将1- 9999直接的素数分别写入三个文件中(1- 99之间的素数保存在a.txt中,100- 999之间的素数保存在b.txt中,1000- 9999之间的素数保存在c.txt中)。
107
107
108
108
``` Python
109
109
from math import sqrt
You can’t perform that action at this time.
0 commit comments