首页 > 编程语言 >【笨方法学python】ex15 - 读取文件

【笨方法学python】ex15 - 读取文件

时间:2022-10-05 04:44:05浏览次数:53  
标签:again 读取 python ex15 filename file print txt 方法学

代码如下:

点击查看代码
# -*-coding:utf-8- -*-
# 读取文件

from sys import argv

script, filename = argv

txt = open(filename)

print "Here's your file %r:" % filename
print txt.read()

print "Type the filename again:"
file_again = raw_input(">")

txt_again = open(file_again)

print txt_again.read()

待读取文件:ex15


This is stuff I typed into a file.
It is really cool stuff.
Lots and lots of fun to have in here.


执行结果:
image

标签:again,读取,python,ex15,filename,file,print,txt,方法学
From: https://www.cnblogs.com/TiramisuPS/p/16754979.html

相关文章