Get the App
SLTechnology News&Howtos  ›  Development  › 

How to configure the file path for python

Shulou Source: shulou.com Published: 2022-06-03 15:33:49 11月14日 Update

This article introduces the knowledge of "how to configure the file path for python". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Get the file name of the module where the called function is located, and then get its path.

2. Compared with the path where the configuration file is located, the absolute path of the configuration file is obtained based on the relative path of the configuration file of the module file path and the parent path.

Example

Co_filepath = sys._getframe () .f_code.co_filenamehead, tail = os.path.split (co_filepath) conf_filepath = os.path.join (head,'.. / conf/log.conf') conf_filepath = os.path.normpath (conf_filepath) logsignleton = LogSignleton (conf_filepath) logger = logsignleton.get_logger () "how to configure the file path to python" is here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: File path configuration location content more module knowledge practical learned next function dilemma instance actual situation file name article case tape Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi MariaDB Apple Shulou Technology