# 输入方式 name = input() # 打开文件 # 1.读取数据建议使用: f = open(filename, "rb") content = f.read() f.close() # 2.写入数据建议使用: with open(filename, "wb") as f: f.write(content)
<p>Input()获取输入, open打开文件</p>
获取输入:input()
打开文件:file = open(‘1.txt’, ‘rb’)
content = file.read()
file.close(content)
方式二:with open(“1.txt”,’rb‘)as f:
f.write()
python3中,使用input()函数来接收输入的内容,并使用一个变量接收,程序就收到了输入的信息,开始执行顺序代码;打开文件的方式有两种,一种是:file = open(文件名,"读或者写") ;另一种是:with open(文件名,"读或者写") as f:
这道题你会答吗?花几分钟告诉大家答案吧!
扫描二维码,关注牛客网
下载牛客APP,随时随地刷题