D
D
DevilBoiz2021-05-12 20:16:51
css
DevilBoiz, 2021-05-12 20:16:51

How to write a variable from a function from one file to another?

In file1.py After the user answers the bot's questions, they are written to answer1 and answer2, how do I make sure that these answer1 and answer2 variables are written \ saved in otvet1 and otvet2 in another config.py file?

Here is a piece of file1.py code:

@dp.message_handler(state=Test.Q2)
async def answer_q2(message: types.Message, state: FSMContext):
    # Достаем переменные
    data = await state.get_data()
    answer1 = data.get("answer1")
    answer2 = message.text

    await message.answer("Спасибо за ваши ответы!")
    config.otvet1 = answer1 #это не работает =(
    config.otvet2 = answer2 #это не работает =(
    await message.answer(f'Вы сохранили: +config.otvet1+config.otvet2)
    await state.finish()


here is the code in config.py
otvet1 = ' '
otvet2 = ' '

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Pakhomov, 2018-11-11
@s24344

.cards__list-wrapper {
  margin: 0;
}
.cards__item:first-child, .cards__item:nth-child(5n) {
  padding: 0 15px 0 0;
}
.cards__item:nth-child(4n) {
  padding: 0 0 0 15px;
}

D
DontQuantum, 2021-05-12
@DontQuantum

https://pythonworld.ru/tipy-dannyx-v-python/fajly-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question