import codecs file_path = r'd:\\骅锋\\mall\\layouts\\admin\\components\\AdminHeader.uvue' with codecs.open(file_path, 'r', 'utf-8') as f: text = f.read() text = text.replace('.user-profile-container {\n position: relative;', '.user-profile-container {\n position: relative;\n z-index: 100;\n pointer-events: auto;') with codecs.open(file_path, 'w', 'utf-8') as f: f.write(text)