📜  如何在python代码示例中将用户输入写入文件

📅  最后修改于: 2022-03-11 14:46:15.038000             🧑  作者: Mango

代码示例1
#Print User Input to A File
x = input("Enter blah : ")
y = open('C:\Users\USERNAME\Documents\Doc1.txt', 'w')
y.write(x)

#Convert text to binary and then write to file
x = input("Enter blah : ")
y = open('C:\Users\USERNAME\Documents\Doc1.txt', 'wb')
y.write(x)