输入样例文件内容
代码运行效果截屏图片
#!/sur/bin/nve python
# coding: utf-8
def read_one(f):
''' 从文件中读取一组评判数据 '''
line = f.readline()
if line.strip() == 'START':
one = ''
while 1:
line = f.readline()
if line.strip() == 'END':
return one
one += line
def is_blank(a, b):
''' 比对除空格回车外的字符串 '''
a, b = [i for i in a if i not in ' \n'], [i for i in b if i not in ' \n']
if a == b:
return True
return False
def judge(filename):
''' 评判数据文件 '''
with open(filename) as f:
for i in range(int(f.readline())):
target = read_one(f)
user = read_one(f)
is_blank(target, user)
judge_tip = 'Accepted' if target == user else 'Presentation Error' if is_blank(target, user) else 'Wrong Answer'
print(judge_tip)
if __name__ == '__main__':
filename = '/sdcard/Documents/demo2.txt'
judge(filename) # 调用函数评判输入文件。
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.rcParams['font.sans-serif'] = ['SimHei'] # 设置加载的字体名
plt.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
import jieba
import re
from pyecharts.charts import *
from pyecharts import options as opts
from pyecharts.globals import ThemeType
import stylecloud
from IPython.display import Image