Я использую стек Python Rasa. В одном классе (ActionAgree
), например, из приведенного ниже кода, я использую ввод пользователя (ID
) в качестве имени файла txt. Затем данные будут записаны в этот текстовый файл.
В другом классе (ActionTopic
) я хочу снова открыть этот файл и записать в него некоторые данные. У меня вопрос, как мне достичь этой цели?
Часть моих кодов:
class ActionAgree(FormAction):
def name(self):
return 'action_agree'
def submit(self, dispatcher, tracker, domain):
#this is to get the student ID as his/her input
booking = agree_info.save(tracker.latest_message.get("text"))
put channel: " + str(lic_log))
...
...
...
#using user input to create a txt file
indexFile_senderid = open(str(booking) + '.txt', 'a+', encoding='utf-8')
indexFile_senderid.write('ActionAgree_' + 'student ID: ' + tracker.latest_message.get("text") + str('\n\n'))
indexFile_senderid.close()
return[]
class ActionTopic(FormAction):
def name(self):
return 'action_topic'
def submit(self, dispatcher, tracker, domain):
...
...
return[]