如何输入一个字符串,将其写入一个文本文件,将文件命名为data721.txt.
如何输入一个字符,统计该字符在文data72.txt中出现次数。
如何读取 data721.txt中的内容,将其按相反的顺序写入另个文本文件。
# 第一题
s=input()
with open('data721.txt','w') as f:
f.write(s)
# 第二题
n=input()
with open('data721.txt','r') as f:
print(f.read().count(n))
# 第三题
with open('data721.txt','r') as f:
s=f.read()
with open('another.txt','w') as f:
f.write(s[::-1])