import codecs file_path = r'd:\\骅锋\\mall\\layouts\\admin\\AdminLayout.uvue' with codecs.open(file_path, 'r', 'utf-8') as f: text = f.read() text = text.replace('console.log([AdminLayout] Computing component for activeRouteId: )', 'console.log([AdminLayout] Computing component for activeRouteId: )') text = text.replace('console.log([AdminHeader] goToUserCenter called)', 'console.log([AdminHeader] goToUserCenter called)') with codecs.open(file_path, 'w', 'utf-8') as f: f.write(text)