第三方库: from bs4 import BeautifulSoup with open('path/to/your/saved/html/file.html', 'r', encoding='utf-8') as file: soup = BeautifulSoup(file, 'html.parser') if soup.meta: soup.meta['charset'] = 'utf-8' else: soup.head.append(soup.new_tag('meta', charset='utf-8')) with open('path/to/your/saved/html/file.html', 'w', encoding='utf-8') as file: file.write(str(soup))