forked from ericafnunes/ericafnunes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_readme.py
23 lines (17 loc) · 714 Bytes
/
update_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import datetime
def update_readme():
# Read the existing README.md file
with open('README.md', 'r', encoding='utf-8') as f:
content = f.read()
# Find and remove any existing "Last Updated" lines
lines = content.split('\n')
lines = [line for line in lines if 'Last Updated' not in line]
# Add a new "Last Updated" line with the current timestamp
last_updated = f"Last Updated: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}"
lines.append('')
lines.append(last_updated)
# Write the updated content back to README.md
with open('README.md', 'w', encoding='utf-8') as f:
f.write('\n'.join(lines))
if __name__ == '__main__':
update_readme()