import re

打开文件并读取内容

with open('env.txt', 'r') as file: content = file.read()

使用正则表达式提取USER值

pattern = r'^USER=(.*)$' match = re.search(pattern, content, re.MULTILINE)

if match: user = match.group(1) print("USER值:", user) else: print("未找到USER值")

go用 regex提取envtxt中的USER值

原文地址: https://www.cveoy.top/t/topic/ijJH 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录