代码拉取完成,页面将自动刷新
# -*- coding: utf-8 -*-
"""
@Author: 芮芪懿 QQ1849433491
@Project->File: pygame_train -> file_op.py
@IDE:PyCharm
@File: file_op.py
@Datetime: 2021/7/10 23:48
"""
def read_file():
with open("./resources/rank_list.txt", "r+", encoding="utf-8") as fp:
content = fp.readline()
rank_list = content.split("#")
rank_list_int = []
for rank in rank_list:
rank_list_int.append(int(rank))
rank_list_int.sort()
rank_list_int.reverse()
return rank_list_int
def write_file(rank_list=[]):
with open("./resources/rank_list.txt", "w+", encoding="utf-8") as fp:
# rank_list = [8004, 7877, 7457, 474, 454]
# rank_list = [8004, 7877, 7457, 474, 454]
# rank_list.append(787)
rank_list.sort()
rank_list.reverse()
# print(rank_list)
rank_list_str = ""
for i in range(len(rank_list)-1):
rank_list_str += f"{rank_list[i]}#"
rank_list_str = rank_list_str[0:len(rank_list_str)-1]
print(rank_list_str)
fp.write(rank_list_str)
# print(rank_list)
pass
pass
if __name__ == '__main__':
write_file(read_file())
# read_file()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。