T
T
Timofey Yangin2022-01-08 21:49:34
Python
Timofey Yangin, 2022-01-08 21:49:34

How to add an object from the config?

The bottom line is this:
You need to add text to this variable, from the

config Example (config):

[profile]
profile = 1

url = https://site.site/(profile)

In the end, everything should look like this https://site.site/1:

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Gusarev, 2022-01-08
@imducked

import configparser  # Стандартная библиотека Питона

config = configparser.ConfigParser()
config.read('config.ini')

profile_url = config['profile']['url'].replace('(profile)', config['profile']['profile'])
print(profile_url)

Ready

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question