gpt4 book ai didi

python - OJ 说我的 python 程序编译错误,即使它在我的计算机上运行良好(ubuntu 18.04)

转载 作者:行者123 更新时间:2023-12-01 08:30:44 25 4
gpt4 key购买 nike

我为我的作业编写了一个简单的Python程序,它希望我们将输入给出的三个整数相加。我将其提交给学校的oj(在线法官)系统,但我收到“编译器错误”

该程序在我运行 ubuntu 18.04 amd64 的个人计算机上运行得很好,但我无法让它通过 oj 测试。我真的不知道出了什么问题,因为 oj 没有给出任何消息,只有最终状态“编译器错误”

import sys

a = input()
b = input()
c = input()
a = int(a)
b = int(b)
c = int(c)
answer = a + b + c
print(f"The answer is {answer}")

这是我在计算机上运行程序时的结果:

ubuntu@VMware:~/python-intro $ python3 1003.py
3
4
5
The answer is 12

和我的计算机系统:

ubuntu@VMware:~/python-intro $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic

怎么会是oj上的编译错误呢?我已确认我的提交语言是“python 3”而不是“python 2”或其他语言。

最佳答案

也许你的 OJ 的 python 3 版本不是 python 3.6。并且您不能在低于 3.6 的 python 版本上使用 f-string。

我建议将您的字符串格式更改为:

print("The answer is {answer}".format(answer=answer))

关于python - OJ 说我的 python 程序编译错误,即使它在我的计算机上运行良好(ubuntu 18.04),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53919422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com