Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
5615 Представления

with open('WHOUSE.txt', 'r') as f_read:
            file_data = f_read.read()
            print 'file_data', file_data
            data_encode = file_data.encode('utf8').encode('base64')
            data_decode = data_encode.decode('base64','strict')
            print 'data_decode',data_decode

        values = {
            'name': 'WHOUSE.txt',
            'datas_fname': 'WHOUSE.txt',
            'res_model': 'ir.ui.view',
            'res_id': False,
            'type': 'binary',
            'public': True,
            'datas': data_decode,

        }


I think i have a problem in decoding, I don't which part and what do I do.

Аватар
Отменить
Лучший ответ

Hello Dee Yoj,    

I think you need to pass encoded data in values as below,

You can try below code 

Hope this will help you

 values = {
            'name': 'WHOUSE.txt',
            'datas_fname': 'WHOUSE.txt',
            'res_model': 'ir.ui.view',
            'res_id': False,
            'type': 'binary',
            'public': True,
            'datas': data_encode,
        }

Аватар
Отменить
Автор

this is my first code, but when I download the txt file all the text are in one line only.. I put \n in each line but still when I download it, it's in one line.

Related Posts Ответы Просмотры Активность
1
нояб. 17
9164
1
янв. 23
6307
1
мар. 21
18882
0
сент. 17
5350
0
февр. 16
5126