输入文件名
# 以读的方式打开文件
oldFile = open(oldFileName,'rb')
提取文件的后缀
fileFlagNum = oldFileName.rfind('.')
if fileFlagNum > 0:
fileFlag = oldFileName[fileFlagNum:]
组织新的文件名字
newFileName = oldFileName[:fileFlagNum] + '-bakcup' + fileFlag
创建新文件
newFile = open(newFileName, 'wb')
把旧文件中的数据,一行行复制到新文件中
for lineContent in oldFile.readlines():
newFile.write(lineContent)
关闭文件
oldFile.close()
newFile.close()
f = open("1909c2", mode="r", encoding="utf-8")
print(f.readlines())
f.close()
file_1 = open(file_name,"r")
link = file_1.readlines()
print(link)
i = 0
list_1 = []
s = 0
o = 0
for j in link:
k = int(j[len(j) -3] + j[len(j) - 2])
s += k
if k > 60:
# print((j[j.index(",")]))
d = j.index(",")
print("%s超过了60分"%(j[0:d]))
if j[0:d][0] == "L":
print("%s的名字是'L'开头的"%j[0:d])
print("总分是%s" % s)