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

Hi All, 

I have a custom module which exports xlsx accounting reports.  When I export the report, it is saved in /var/lib/odoo directory instead in Downloads folder. Temporarily I set the path to home:

home = os.getenv("HOME")

When I print the home, the result is /var/lib/odoo. How do I get the home directory?


Thanks!

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

try 

from os.path import expanduser
home = expanduser("~")

or if you are in python 3.5 + try

from pathlib import Path
home = str(Path.home())


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

Hi Hilar,

I've tried both but the output path is still /var/lib/odoo..

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 7 25
1886
3
thg 2 25
15089
1
thg 4 25
2163
Export Import Đã xử lý
1
thg 4 25
2120
0
thg 10 23
1465