python怎么設置最后幾個字不打印?
def erase_lastchar(fname): ''' 把給定文本最后一個字符去掉,再保存 ''' content = open(fname).read() with open(fname,'w') as handle: handle.write(content[:-1]) # 批量處理文本文件 import glob map(erase_lastchar, glob.glob('*.txt'))
python怎么設置最后幾個字不打印?
def erase_lastchar(fname): ''' 把給定文本最后一個字符去掉,再保存 ''' content = open(fname).read() with open(fname,'w') as handle: handle.write(content[:-1]) # 批量處理文本文件 import glob map(erase_lastchar, glob.glob('*.txt'))