如何删除tkinter Scrolledtext小部件中每行末尾的空白空间?如何删除python tkinter ScrolledText小部件内每行末尾的空白空间?
INPUT
TXT没有在每一行的末尾有空白文件。
CODE
def openCommand():
ftypes = [('Text files', '*.txt')] # allow only txt files
filePath = tkFileDialog.askopenfile(parent=root,mode='rb',title=' Select a file', filetypes = ftypes)
if filePath != None:
contents = str(filePath.read()).strip()
contents = contents.rstrip()
contents = contents.lstrip()
textPad.insert('1.0',contents.strip())
OUTPUT
一旦插入该文件的内容,在textpad:
textPad = ScrolledText(root, width=100, height=30, undo=True)
textPad.pack()
我将看到的空的空间在每一行的末尾。
注意
我已经尝试所有与Python字符串修整有关。