以下是Python的代码实现:
s ="832479347829490"
result = ""
# 顺序查找并连接偶数字符
for c in s:
if c.isdigit() and int(c) % 2 == 0:
result += c
# 将结果逆序并存入文件
with open("result3.txt", "w") as f:
f.write(result[::-1])
代码首先定义了一个空字符串 result
用于存储所有查找到的偶数字符。接着,代码遍历输入字符串 s
中的每个字符,如果该字符是数字且