python读文件操作
Python
# 打开名为 '111.txt' 的文件,以只读模式读取,文件编码为 utf-8
with open('111.txt', 'r', encoding='utf-8') as f:
# 读取文件的所有行,并将其存储在列表 titles 中
titles = f.readlines()
# 遍历列表 titles 中的每一行
for title in titles:
# 去除字符串两端的空白字符(如空格、换行符等)
title = title.strip()
# 以冒号为分隔符,将字符串分割成多个部分,并取最后一部分
money = title.split(':')[-1]
# 打印分割后的最后一部分
print(money)