#10-1
with open('learning_python.txt') as file_object:
contents=file_object.read()
print(contents.rstrip())
with open('learning_python.txt') as file_object:
for line in file_object:
print(line.rstrip())
with open('learning_python.txt') as file_object:
lines=file_object.readlines()
for line1 in lines:
print(line1)
#10-2
with open('learning_python.txt') as file_object:
lines=file_object.readlines()
for line1 in lines:
print(line1.replace('python','C'))#replace 不会改变原字符串,而是生成新的字符串
蟒蛇书:python编程:从入门到实践 10-1至10-2
最新推荐文章于 2024-08-15 01:55:01 发布