我有一些结果我可以像这样打印出来:
print ("BugID : ", bugID, '\n' , "Bug Description : ", desc, '\n' , "Classification : ", classification, '\n', "Component : ", component, '\n', "Version : ", version, '\n', "Operating System : ", opsystem, '\n', "Status : ", status )
如何在文本文件中编写它们?
答案 0 :(得分:0)
with open("log.txt","w") as my_log_file:
print("a","bunch","of","stuff",file=my_log_file)
# ^ this is the part thats important
我认为你需要的只是
这里解释https://docs.python.org/3/library/functions.html?highlight=print#print
答案 1 :(得分:0)
来自http://www.tutorialspoint.com/python/python_files_io.htm
# Open a file
fo = open("foo.txt", "wb")
fo.write( "Python is a great language.\nYeah its great!!\n");
# Close opened file
fo.close()