脚本.py
code = open("my_solution.py").read()
input_stream = StringIO(input_file)
sys.stdin = input_stream
output_stream = sys.stdout = StringIO()
exec(code)
my_solution.py
for _ in range(int(input())):
n = int(input())
ar = list(map(int, input().split()))
y = min(ar)
print(sum([x - y for x in ar if x > y]))
输出:
exec(code) File "<string>", line 6, in <module> File "<string>", line 6, in <listcomp> NameError: name 'y' is not defined
为什么会发生这种事?