python
用类实现一个字典,完成单词的增删查改。
本地使用是可以的,但是放到作业系统就提示我“Your core has sensitive words"。
能帮我看看那个函数不安全吗?
class Dic:
def __init__(self, n):
self.num = n
self.dic = {}
self.word = None
def add(self, word):
self.word = word
en, ch = self.word.split()
self.dic[en] = ch
def search(self, word):
self.word = word
if self.word in self.dic.keys():
print(self.dic[self.word])
else:
print('meiyou')
def dell(self, word):
self.word = word
del self.dic[self.word]
def op1(n):
n = int(n)
my_dic = Dic(num)
for i in range(n):
op2 = input()
word1 = input()
if op2 == 'add':
my_dic.add(word1)
elif op2 == 'search':
my_dic.search(word1)
elif op2 == 'del':
my_dic.dell(word1)
num = input()
op1(num)
感谢!!!!!
添加信任