#!/usr/bin/env python # -*- coding: utf-8 -*- from z3 import * # 创建约束解析器 solver = Solver() # 定义变量 m1 = Int('m1') m2 = Int('m2') m3 = Int('m3') m4 = Int('m4') m5 = Int('m5') m6 = Int('m6') m7 = Int('m7') # 添加约束条件 # 参数前7个ascii等于0x321 solver.add(m1+m2+m3+m4+m5+m6+m7==0x321) # 约束每个解的范围都是在可见字符串 solver.add(32<=m1) solver.add(m1<127) solver.add(32<=m2) solver.add(m2<127) solver.add(32<=m3) solver.add(m3<127) solver.add(32<=m4) solver.add(m4<127) solver.add(32<=m5) solver.add(m5<127) solver.add(32<=m6) solver.add(m6<127) solver.add(32<=m7) solver.add(m7<127) if solver.check() == sat: flag = solver.model() print(flag) else: print("no answer")