更正了部分文档中的bug
parent
2c1991cf6f
commit
bef6a30aeb
|
@ -53,15 +53,15 @@ yum -y install wget gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlit
|
|||
下载Python源代码并解压缩到指定目录。
|
||||
|
||||
```Shell
|
||||
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.1.tar.xz
|
||||
xz -d Python-3.7.1.tar.xz
|
||||
tar -xvf Python-3.7.1.tar
|
||||
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
|
||||
xz -d Python-3.7.3.tar.xz
|
||||
tar -xvf Python-3.7.3.tar
|
||||
```
|
||||
|
||||
切换至Python源代码目录并执行下面的命令进行配置和安装。
|
||||
|
||||
```Shell
|
||||
cd Python-3.7.1
|
||||
cd Python-3.7.3
|
||||
./configure --prefix=/usr/local/python37 --enable-optimizations
|
||||
make && make install
|
||||
```
|
||||
|
|
|
@ -157,7 +157,7 @@ class Clock(object):
|
|||
if self._hour == 24:
|
||||
self._hour = 0
|
||||
|
||||
def __str__(self):
|
||||
def show(self):
|
||||
"""显示时间"""
|
||||
return '%02d:%02d:%02d' % \
|
||||
(self._hour, self._minute, self._second)
|
||||
|
@ -166,7 +166,7 @@ class Clock(object):
|
|||
def main():
|
||||
clock = Clock(23, 59, 58)
|
||||
while True:
|
||||
print(clock)
|
||||
print(clock.show())
|
||||
sleep(1)
|
||||
clock.run()
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ if __name__ == '__main__':
|
|||
main()
|
||||
```
|
||||
|
||||
要将文本信息写入文件文件也非常简单,在使用`open`函数时指定好文件名并将文件模式设置为`'w'`即可。注意如果需要对文件内容进行追加式写入,应该将模式设置为`'a'`。如果要写入的文件不存在会自动创建文件而不是引发异常。下面的例子演示了如何将1~9999直接的素数分别写入三个文件中(1~99之间的素数保存在a.txt中,100~999之间的素数保存在b.txt中,1000~9999之间的素数保存在c.txt中)。
|
||||
要将文本信息写入文件文件也非常简单,在使用`open`函数时指定好文件名并将文件模式设置为`'w'`即可。注意如果需要对文件内容进行追加式写入,应该将模式设置为`'a'`。如果要写入的文件不存在会自动创建文件而不是引发异常。下面的例子演示了如何将1-9999直接的素数分别写入三个文件中(1-99之间的素数保存在a.txt中,100-999之间的素数保存在b.txt中,1000-9999之间的素数保存在c.txt中)。
|
||||
|
||||
```Python
|
||||
from math import sqrt
|
||||
|
|
Loading…
Reference in New Issue