input_example = QInputDialog.getText(self, "", "Please type your name here:") # this allows the users to enter their name
myfile = open(str(input_example) + ".txt","w") #this creates a new file with what the user has entered as the name of the file
myfile.write("Here is their score: " + str(self.points_Q11_L1) + "\n") # this prints their score
myfile.close()
上面的代码询问用户名称,当他们点击确定时,它会创建文件,并将文件标题为("Example Name", True)
有没有办法删除它,以便它不会显示?
答案 0 :(得分:1)
将input_example[0]
放在您创建文件的位置,只选择字符串结果。