关于rewind和seek
#rewind和seek字面意思能看明白,我把有关rewind和seek的命令删去之后,变成了python ex20.py record1.txt
First let's print the whole file:
kobe
james
harden
Now let's rewind, kind of like a tape.
Let's print three lines:
1
2
3
这两个命令存在时候 是
1 kobe
2 james
3 harden
求解一下
from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
def rewind(f):
f.seek(0)
def print_a_line(line_count, f):
print(line_count, f.readline())
current_file = open(input_file)
print("First let's print the whole file:\n")
print_all(current_file)
print("Now let's rewind, kind of like a tape.")
rewind(current_file)
print("Let's print three lines:")
current_line = 1
print_a_line(current_line, current_file)
current_line += 1
print_a_line(current_line, current_file)
current_line += 1
print_a_line(current_line, current_file) 看不明白你想问什么或者你想表达什么
难道你是外国人吗,非要用英语去阐述一些事情 wp231957 发表于 2021-1-28 07:44
看不明白你想问什么或者你想表达什么
难道你是外国人吗,非要用英语去阐述一些事情
是照着书上打出来的,书是外国人写的{:10_277:}
页:
[1]