Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在需要缩短 14 行时遇到问题,这些行可以:打开并读取特定文件。我已经在一个循环中缩短了这些行中的每一行的 close() 标签,但我无法想象如何使用这些行来做到这一点:
def read_utf8(filename): with codecs.open(filename, mode="r", encoding="utf8") as f: return f.read() header = read_utf8("static/header")