小编lay*_*y3r的帖子

close()Python中的变量

我有以下代码:

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()
Run Code Online (Sandbox Code Playgroud)

而在我的书的练习,它说一个"有你的脚本也做了close()txttxt_again变量.当你与他们所做的要关闭文件是很重要的.

如何关闭变量?

python file

2
推荐指数
1
解决办法
2881
查看次数

标签 统计

file ×1

python ×1