用列表加载Txt文件中内容(按行读取,strip去掉可能含有的\n影响表格成像,可以忽略)
Dictionaries=[]#列表初始化
def WriteText():
file =open("text.txt")#将列表中内容追加到字典里,若空则break
while True:
text =file.readline()
textcl=text.strip('\n')
if not text:
break
Dictionaries.append(textcl)
file.close()
通过删除列表中的元素从而重新赋值Txt中的文本
def DeleteFunction(Dictionaries,item2):#item2为指定删除列表中元素的位置
text=open("text.txt","a")#选择append
i=0
j=0
while True:
if i < 3:
del Dictionaries[item2]
i+=1
else:
break
text.truncate(0)#删除后清空列表,然后重新append
while True:
if j
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)