将其向前推进: f = open('foo', 'r') error_log.write('Unable to open foo : %s\n' % e) data = f.read()我突然想到,else clause解决的角落问题仍然可以通过一个nested try...except来避免,而不需要: f = open(
我的代码: fname = "text.txt"lines = text_file.readlines() linenumber = int(input("Please enter a line number or press 0 to quit: ")) print("Thanks for using the program")text_
TurtleGraphicsError("bad color string: %s" % str(color))因此,我添加了tryexcept代码,该代码用于捕获TurtleGraphicsError错误。但是,当我运行代码时,会发生以下情况:NameError: name 'TurtleGraphicsError' is not