From bcbf532148239031852d5ed76820d5c0ea58bb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E4=B8=80=E5=8D=9A?= <2758032428@qq.com> Date: Mon, 23 Sep 2024 02:29:18 +0000 Subject: [PATCH] =?UTF-8?q?update=20Python=E9=AB=98=E7=BA=A7=E7=BC=96?= =?UTF-8?q?=E7=A8=8B/=E4=B8=8A=E4=B8=8B=E6=96=87=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=99=A8=20=E8=AF=BB=E6=96=87=E6=9C=AC=E6=96=87=E4=BB=B6.py.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 赵一博 <2758032428@qq.com> --- ...257\273\346\226\207\346\234\254\346\226\207\344\273\266.py" | 3 +++ 1 file changed, 3 insertions(+) diff --git "a/Python\351\253\230\347\272\247\347\274\226\347\250\213/\344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250 \350\257\273\346\226\207\346\234\254\346\226\207\344\273\266.py" "b/Python\351\253\230\347\272\247\347\274\226\347\250\213/\344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250 \350\257\273\346\226\207\346\234\254\346\226\207\344\273\266.py" index 845b884..d640a48 100644 --- "a/Python\351\253\230\347\272\247\347\274\226\347\250\213/\344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250 \350\257\273\346\226\207\346\234\254\346\226\207\344\273\266.py" +++ "b/Python\351\253\230\347\272\247\347\274\226\347\250\213/\344\270\212\344\270\213\346\226\207\347\256\241\347\220\206\345\231\250 \350\257\273\346\226\207\346\234\254\346\226\207\344\273\266.py" @@ -48,7 +48,10 @@ import contextlib def open_func(file_name): # __enter__方法 print('open file:', file_name, 'in __enter__') + file_handler = open(file_name, 'r') + # 注释:如由于文件编码问题导致,指定编码格式为'utf-8' + # file_handler = open(file_name, 'r', encoding='utf-8') # 【重点】:yield yield file_handler -- Gitee