【发布时间】:2021-08-29 17:56:51
【问题描述】:
为了逐行而不是逐行获取输出,我想开始使用 /n 命令。
这是我认为应该放置的一段代码:
password_for = input('This password is for: ')
your_pass = 'Your password for {} is: {}'.format(password_for, password)
save_path = '/Users/"MyUsername"/Desktop'
name_of_file = input("What is the name of the file: ")
completeName = os.path.join(save_path, name_of_file+".txt")
with open(completeName, "a+") as file1:
file1.write(your_pass)
/n 命令应该用于获取应该写入(输出)的文本,逐行如下:
Input 1
input 2
但是现在输出是这样的:
Input1Input2
也许 /N 不是解决方案?告诉我!
【问题讨论】:
-
/n命令是什么意思? -
@tobias 我猜他的意思是换行。
-
是的,我希望我的输入是:输入 1 输入 2 而现在是这样的:输入 1Input2
-
使用
\n- 表示新行。 -
这能回答你的问题吗? How to append new data onto a new line