我想做的基本上是我有这个文件,其中的数据在不同的行中,除了最后一段是传记,可能跨越多行。传记可能有任意多行,我只知道它从第 5 行开始。现在我需要的是一种从第五行到文件末尾检索传记的方法,但我不知道该怎么做。提前致谢。
这是我尝试过的:
from tkinter import *
import os
class App:
charprefix = "character_"
charsuffix = ".iacharacter"
chardir = "data/characters/"
def __init__(self, master):
self.master = master
frame = Frame(master)
frame.pack()
# character box
Label(frame, text = "Characters Editor").grid(row = 0, column = 0, rowspan = 1, columnspan = 2)
self.charbox = Listbox(frame)
for chars in []:
self.charbox.insert(END, chars)
self.charbox.grid(row = 1, column = 0, rowspan = 5)
charadd = Button(frame, text = " Add ", command = self.addchar).grid(row = 1, column = 1)
charremove = Button(frame, text = "Remove", command = self.removechar).grid(row = 2, column = 1)
charedit = Button(frame, text = " Edit ", command = self.editchar).grid(row = 3, column = 1)
for index in self.charbox.curselection():
charfilelocale = self.charbox.get(int(index))
charfile = open(app.chardir + app.charprefix + app.charfilelocale, 'r+')
charinfo = str.splitlines(0)