From 50bcf65ddc7ea4f517d7de255ecc2e94161c82d4 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 27 Jun 2021 14:59:11 +0800 Subject: [PATCH] save project --- diy.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/diy.py b/diy.py index 339c6af..e77ba4b 100644 --- a/diy.py +++ b/diy.py @@ -1,7 +1,11 @@ # 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本' -#file1=open(r'D:\zm\新建文件夹 (2)\新建文本文档.txt','a',encoding='utf-8') -#file1.write('小兰:12本 小丽:11本 李文:9本 张伟:16本') -#file1.close() +file1=open(r'D:\zm\新建文件夹 (2)\新建文本文档.txt','a',encoding='utf-8') +file1.write('小兰:12本 小丽:11本 李文:9本 张伟:16本\n') +file1.close() file1=open(r'D:\zm\新建文件夹 (2)\新建文本文档.txt','a',encoding='utf-8') file1.write('小强:12本\n') -file1.close() \ No newline at end of file +file1.close() +with open(r'D:\zm\新建文件夹 (2)\新建文本文档.txt','r',encoding='utf-8')as file1: + for data in file1: + if'小强:12本' in data: + print('在') \ No newline at end of file -- libgit2 0.25.0