If you want a newline, you have to write one explicitly. The usual way is like this:
hs.write(name + "
")
This uses a backslash escape,
, which Python converts to a newline character in string literals. It just concatenates your string, name
, and that newline character into a bigger string, which gets written to the file.
It's also possible to use a multi-line string literal instead, which looks like this:
"""
"""
Or, you may want to use string formatting instead of concatenation:
hs.write("{}
".format(name))
All of this is explained in the Input and Output chapter in the tutorial.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…