python-从字符串中排除文本

时间:2018-12-28 05:05:51

标签: python string time

我有一个单独的系统,正在导出到AVExprt.txt。 在该导出中,其时间为AM / PM(无空格)。 如何从时间中排除AM / PM?

def main():

    import linecache
    filename='AVExprt.txt' 
    appendfile='AVExprt_Main.txt'
    date=linecache.getline(filename,2) 
    remove_lines= 5 

    with open(filename,'r') as file_object:
        lines = file_object.readlines()
        for i in range(remove_lines):
            del lines[0]

    with open(appendfile,'a') as file_object:   
        for line in lines:
            line = date.rstrip() + "," + line
            file_object.write(line)

if __name__== "__main__":
    main()

0 个答案:

没有答案