如果阅读tryCatch函数的文档,您会看到以下用法: tryCatch(expr, ..., finally) 也就是说:您想要“try”的实际表达式是第一个参数,处理程序(您尝试编写的)在后面: tryCatch( as.integer(n_top_features), error = function (e) { stop('ERROR: n_top_features variable should be integer!') }) 但是,...
检查 https://pynative.com/python-class-variables/ https://www.w3schools.com/python/python_classes.asp 我尝试您的代码: import osimport torchclass sequence: def __init__(self): self.id_to_char = {} self.char_to_id = {} def update_vocab(self, txt): chars = list(txt) for i, char...