diff --git a/Test4.py b/Test4.py new file mode 100644 index 0000000..4329ac0 --- /dev/null +++ b/Test4.py @@ -0,0 +1,17 @@ +def write_config(): + print("新人脸训练结束") + f = open('config.txt', "a") + T = Total_face_num + f.write(str(T) + " User" + str(T) + " \n") + f.close() + id_dict[T] = "User" + str(T) + + # 这里修改文件的方式是先读入内存,然后修改内存中的数据,最后写回文件 + f = open('config.txt', 'r+') + flist = f.readlines() + flist[0] = str(int(flist[0]) + 1) + " \n" + f.close() + + f = open('config.txt', 'w+') + f.writelines(flist) + f.close()