Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
5685 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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,
        }

Ảnh đại diện
Huỷ bỏ
Tác giả

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.

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 11 17
9217
1
thg 1 23
6388
1
thg 3 21
18963
0
thg 9 17
5398
0
thg 2 16
5164