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() overlay_css = r''' .user-dropdown-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 1000; background-color: transparent; } ''' if '.user-dropdown-overlay' not in text: text = text.replace('', overlay_css + '\n') text = text.replace('z-index: 99;', 'z-index: 1001;') text = text.replace('z-index: 90;', 'z-index: 1001;') text = text.replace('z-index: 150;', 'z-index: 1001;') text = text.replace('.user-dropdown {', '.user-dropdown {\n z-index: 1002;') with codecs.open(file_path, 'w', 'utf-8') as f: f.write(text)