I have the following code in a text file:
Host: 0.0.0.0 Port: 80
This is my python code:
with open('config.txt', 'r') as configfile:
lines = configfile.readlines()
lines.split(': ')
HOST = lines[1]
PORT = lines[3]
print(f'Your host is {HOST} and port is {PORT}')
But I get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
lines.split(': ')
AttributeError: 'list' object has no attribute 'split'
How can I fix this? I'm fairly new to python
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…