How can i modify information in a .properties file through python Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of How can i modify information in a .properties file through python without wasting too much if your time.

The question is published on by Tutorial Guruji team.

i have a .properties file that statesserver-ip= and i made a python program that identifies my ipv4, but i want it to go to the proprieties file through the same program and get server-ip=(my ipv4)

import socket    
socket.gethostbyname(hostname)

I’ve tired many diferent types of solutions, please a need help

Answer

If .properties doesn’t have sections (usually doesn’t) you could check this answer: – link

Else, you could use configParser:

import configparser

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

host = config['section-name']['server-ip']
We are here to answer your question about How can i modify information in a .properties file through python - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji