x=d(x) x=t(x) print(x)
2.写出下面程序的执行结果__________________。 x=30 def func():
global x x=20
func() print(x)
文件
一、填空题
1. Python可以使用函数_________打开文件。
2. 文件操作可以使用_________方法关闭流,以释放资源。
3. 当已存在一个abc.txt文件时, 语句??????????????????????????????????????myfile=open(\的功能是
_________________________________。 二、思考题
1. 使用open()函数时,指定打开文件的模式mode有哪几种?其默认打开模式是什么? 2. 对文本文件的读有哪些方法,写有哪些方法?
3. 以下程序实现从文件“moon.txt”读出前5个字符,并输出。 myfile=open(\
s= #读取5个字符 print(s)
#关闭文件