python去除ufeff、xa0、u3000

不知道为什么,明明是utf-8偏偏会遇到bom的问题,那就奥里给
\u2022

def u8togbk(self, infn, outfn):  
    with open(infn, 'r', encoding='utf-8') as f:  
        reader = csv.reader(f)  
        results = list(reader)  
        
    results[0][0] = results[0][0].replace('\ufeff', '').replace('\xa0', '').replace('\u3000', '').replace('\u2022', '')

    with open(outfn, 'w', encoding='gbk', newline='') as f:  
        writer = csv.writer(f)  
        for result in results:  
            writer.writerow(result) 

universe_king
3.4k 声望678 粉丝