这是我的密码:
filenames = []
data = []
found = False
axconfig = open('axcfgpasww.dat', "r")
dictionnary = open("hello.txt", "r")
output_value = "bonjour"
for line in axconfig:
for word in dictionnary:
element = word.split("=")[0]
if element in axconfig:
# old_value = line.split("=")
# data.append(line.replace(old_value, output_value+'\n'))
# found = True
# else:
# data.append(line)
print(element)
if not found:
print('No match found')
# Create a new file, from data array
with open("olivier.txt", 'w') as outfile:
for line in data:
outfile.write(line)
动态值为“元素”。你知道吗
我有一个.txt文件,它有关键字,希望用.txt文件中的值查看“element”。你知道吗
但我的代码不起作用。。 它只会增加奥利维尔.txt第一行axcfgpasww.dat文件.. 而且还返回“找不到匹配项”
谢谢你们!你知道吗
编辑:
axcfgpasww.dat
T72_BANK_IDENTIFIER_CODE_3=SOAPFR22
T72_ISSUER_COUNTRY_CODE_3=FR
T72_MERCHANT_ID_3=
T72_VAS_SCHEME_IDENTIFIER_3=
hello.txt
T72_VAS_SERVICE_IDENTIFIER_7=
T72_VAS_SCHEME_IDENTIFIER_3=
为了方便起见,如果我将两者都视为文本文件。你知道吗
下面的代码将用hello匹配axconfig的每一行,然后打印匹配的内容,并且还将存储一个名为“value”的变量的值
线路有问题:
if element in axconfig:
请尝试:
if element in line.split("=")
相关问题 更多 >
编程相关推荐