'Provides "Strip trailing whitespace" under the "Format" menu.'class Rstrip:def __init__(self, editwin):self.editwin = editwindef do_rstrip(self, event=None):text = self.editwin.textundo = self.editwin.undoundo.undo_block_start()end_line = int(float(text.index('end')))for cur in range(1, end_line):txt = text.get('%i.0' % cur, '%i.end' % cur)raw = len(txt)cut = len(txt.rstrip())# Since text.delete() marks file as changed, even if not,# only call it when needed to actually delete something.if cut < raw:text.delete('%i.%i' % (cur, cut), '%i.end' % cur)undo.undo_block_stop()if __name__ == "__main__":from unittest import mainmain('idlelib.idle_test.test_rstrip', verbosity=2,)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。