摘要
针对Python程序自动评测过程中被测试程序输入输出流重定向问题进行研究。分析了基于操作系统输入输出重定向方法的缺点与不足,基于Python的动态性提出了Python伪装文件类对象输入输出重定向方法。设计并实现了满足标准输入输出流接口特性的伪装文件对象,在Python程序内部接管输入流和输出流,提高了重定向接口的灵活性,减少磁盘空间占用,严格限制输出流数据尺寸,保障评测过程稳定进行。该方法在实际应用中效果良好。
The paper studies problems about the IO stream redirection in the automatic evaluation of python language programs.Thepaper analyzes and points out shortcomings of the OS-based IO redirection method,and proposes an IO redirection method using python masquerading file class object.The paper designsand implement masquerading file class objectwhich meets the characteristics of standard IO stream interfaces.This object takes over IO streams inside a python program,increases flexibility of the redirection interface,reduces disk space usage,limits the output stream data size strictly,ensures the stability of the automatic evaluationprocess.This method works well in practical applications.
作者
亓雪冬
李霞
QI Xuedong;LI Xia(Information Construction Department,China University of Petroleum(East China),Qingdao,Shandong 266580,China;College of Information and Control Engineering,China University of Petroleum(East China),Qingdao,Shandong 266580,China)
出处
《微型电脑应用》
2020年第6期90-92,共3页
Microcomputer Applications