class File:
name: str
context: str
file: open
def __init__(self, name):
self.name = name
def open(self):
self.file = open(self.name)
def read(self):
return self.file.read()
def write(self, text):
self.file.write(text)
def close(self):
self.file.close()
def __del__(self):
self.file.close()
class File:
name: str
context: str
file: open
def __init__(self, name):
self.name = name
def open(self):
self.file = open(self.name)
def read(self):
return self.file.read()
def write(self, text):
self.file.write(text)
def close(self):
self.file.close()
def __del__(self):
self.file.close()
#1
更多评论
package main
type F interface {
read() string
write() string
open()
close()
}
type f struct {
name string
err error
}
func main() {
}
#2