python - 如何在epicbox中提供超过1个输入参数
问题描述
我正在尝试使用epicbox来运行 python 代码。我面临两个问题。这是我的代码:
import epicbox
import pprint
untrusted_code = b"""
a = input()
print(a)
b = input()
print(b)"""
epicbox.configure(
profiles=[
epicbox.Profile('python', 'python')
]
)
files = [{'name': 'main.py', 'content': untrusted_code}]
limits = {'cputime': 1, 'memory': 64}
result = epicbox.run('python', 'python main.py', files=files, limits=limits, stdin="12 19")
pprint.pprint(result)
首先,我不确定如何在标准输入中放置超过 1 个输入参数,其次,它在输出中给了我以下错误:
{
'duration': 0.098507,
'exit_code': 1,
'oom_killed': False,
'stderr': b'Traceback (most recent call last):\n File "/sandbox/main.py", li'
b'ne 4, in <module>\n b = input()\nEOFError: EOF when reading a l'
b'ine\n',
'stdout': b'12 19\n',
'timeout': False
}
解决方案
我想到了。我需要\n
在标准输入参数之间放置:
epicbox.run('python', 'python main.py', files=files, limits=limits, stdin='12\n13')
推荐阅读
- java - Mac OSX 上的 Java 10 辅助启动器的替代方案是什么?
- javascript - php中的jquery ajax停止重新加载页面
- javascript - EmberJS - 清除子组件上的表单字段
- go - 使用 Go 提供静态文件会产生 404 错误
- prolog - 列表中元素的最大间隙,Prolog
- android - BotomSheetDialog 在充气时崩溃:ClassCastException CoordinatorLayout 无法转换为 FrameLayout
- angular - Angular patchValue 未设置输入字段值
- apache-spark - SparkLauncher 构造函数不起作用
- javascript - jQuery 的强制动态字段
- excel - MsgBox 代码不起作用