From 1094a2fa28066918368c1dd58a0aaf7502858920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B4=E6=9C=9B?= <1378277891@qq.com> Date: Sat, 26 Mar 2022 07:23:41 +0000 Subject: [PATCH 1/5] add name.txt. --- name.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 name.txt diff --git a/name.txt b/name.txt new file mode 100644 index 0000000..7ec9ce1 --- /dev/null +++ b/name.txt @@ -0,0 +1,2 @@ +于水望 +2021200061 \ No newline at end of file -- Gitee From bb7c589d59306a1a0e535d940fad36d15b3e9f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B4=E6=9C=9B?= <1378277891@qq.com> Date: Sat, 26 Mar 2022 07:41:24 +0000 Subject: [PATCH 2/5] add homework_01_python. --- homework_01_python/homework | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 homework_01_python/homework diff --git a/homework_01_python/homework b/homework_01_python/homework new file mode 100644 index 0000000..e69de29 -- Gitee From b041b589ce9d5b05935a206a6303d96bc007f967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B4=E6=9C=9B?= <1378277891@qq.com> Date: Sat, 26 Mar 2022 07:44:16 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20home?= =?UTF-8?q?work=5F01=5Fpython/homework?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework_01_python/homework | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 homework_01_python/homework diff --git a/homework_01_python/homework b/homework_01_python/homework deleted file mode 100644 index e69de29..0000000 -- Gitee From f934f49cb2eea14e0bfb6466bca07a7442b6417a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B4=E6=9C=9B?= <1378277891@qq.com> Date: Sat, 26 Mar 2022 07:45:32 +0000 Subject: [PATCH 4/5] add homework_01_python/homework. --- homework_01_python/homework | 598 ++++++++++++++++++++++++++++++++++++ 1 file changed, 598 insertions(+) create mode 100644 homework_01_python/homework diff --git a/homework_01_python/homework b/homework_01_python/homework new file mode 100644 index 0000000..d1f8e2c --- /dev/null +++ b/homework_01_python/homework @@ -0,0 +1,598 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 15 个a符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个b符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 3 个c符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 6 个d符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 14 个e符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 2 个f符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 8 个g符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 6 个h符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 8 个i符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个j符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个k符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 5 个l符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 1 个m符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 15 个n符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 9 个o符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个p符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个q符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 10 个r符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 9 个s符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 13 个t符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 3 个u符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个v符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 3 个w符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个x符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 7 个y符号\n", + "字符串\" One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone. \"中包括 0 个z符号\n" + ] + } + ], + "source": [ + "str1='One is always on a strange road, watching strange scenery and listening to strange music. Then one day, you will find that the things you try hard to forget are already gone.'\n", + "print('字符串\"',str1,'\"中包括',str1.count('a'),'个a符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('b'),'个b符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('c'),'个c符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('d'),'个d符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('e'),'个e符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('f'),'个f符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('g'),'个g符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('h'),'个h符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('i'),'个i符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('j'),'个j符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('k'),'个k符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('l'),'个l符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('m'),'个m符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('n'),'个n符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('o'),'个o符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('p'),'个p符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('q'),'个q符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('r'),'个r符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('s'),'个s符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('t'),'个t符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('u'),'个u符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('v'),'个v符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('w'),'个w符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('x'),'个x符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('y'),'个y符号')\n", + "print('字符串\"',str1,'\"中包括',str1.count('z'),'个z符号')" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(24, [123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432])\n" + ] + } + ], + "source": [ + "def threenum():\n", + " count=0 #计数\n", + " nums=[] #初始化\n", + " for i in range(1,5): #百位循环\n", + " for j in range(1,5):#十位循环\n", + " for x in range(1,5):#个位循环\n", + " if (i!=j) and (i!=x) and(j!=x): #判断不重复的三个数\n", + " num=100*i+10*j+x\n", + " count+=1 #累加\n", + " if num not in nums:\n", + " nums.append(num) #添加到数组\n", + " return count, nums\n", + "if __name__ == '__main__':\n", + " print(threenum())" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "请输入当月利润,单位为万元:36000\n", + "362.95 万元\n" + ] + } + ], + "source": [ + "I = float(input(\"请输入当月利润,单位为万元:\"))\n", + "if I <= 10:\n", + " bns = 10 * 0.1\n", + "elif 10 < I <= 20:\n", + " bns = 10 * 0.1 + (I-10) * 0.075\n", + "elif 20 < I <= 40:\n", + " bns = 10 * 0.1 + 10 * 0.075 + (I-20) * 0.05\n", + "elif 40 < I <= 60:\n", + " bns = 10 * 0.1+ 10 * 0.075 + 20 * 0.05 + (I-40) * 0.03\n", + "elif 60 < I <= 100:\n", + " bns = 10 * 0.1+ 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + (I-60) * 0.015\n", + "elif I > 100:\n", + " bns = 10 * 0.1 + 10 * 0.075 + 20 * 0.05 + 20 * 0.03 + 40 * 0.015 + (I-100) * 0.01\n", + "print(bns, '万元')" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1×1=1\t| \n", + "1×2=2\t| 2×2=4\t| \n", + "1×3=3\t| 2×3=6\t| 3×3=9\t| \n", + "1×4=4\t| 2×4=8\t| 3×4=12\t| 4×4=16\t| \n", + "1×5=5\t| 2×5=10\t| 3×5=15\t| 4×5=20\t| 5×5=25\t| \n", + "1×6=6\t| 2×6=12\t| 3×6=18\t| 4×6=24\t| 5×6=30\t| 6×6=36\t| \n", + "1×7=7\t| 2×7=14\t| 3×7=21\t| 4×7=28\t| 5×7=35\t| 6×7=42\t| 7×7=49\t| \n", + "1×8=8\t| 2×8=16\t| 3×8=24\t| 4×8=32\t| 5×8=40\t| 6×8=48\t| 7×8=56\t| 8×8=64\t| \n", + "1×9=9\t| 2×9=18\t| 3×9=27\t| 4×9=36\t| 5×9=45\t| 6×9=54\t| 7×9=63\t| 8×9=72\t| 9×9=81\t| \n" + ] + } + ], + "source": [ + "for i in range(1,10):\n", + " for j in range(1,i+1):\n", + " print(str(j)+\"×\"+str(i)+\"=\"+str(i*j)+\"\\t\",end=\"| \")\n", + " print(\" \")" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "51\n" + ] + } + ], + "source": [ + "n = 2\n", + "jsum = 0\n", + "osum = 0\n", + "while n < 101:\n", + " if n % 2 == 1:\n", + " jsum += n\n", + " n += 1\n", + " else:\n", + " osum += n\n", + " n += 1\n", + "print(osum-jsum)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[34, 10, 9, 9, 8, 5, 5, 4, 2, 2, 1, 0]\n" + ] + } + ], + "source": [ + "a = [1,10,4,2,9,2,34,5,9,8,5,0]\n", + "a = sorted(a,reverse=True)#对可迭代的对象进行排序操作\n", + "print(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "True\n" + ] + } + ], + "source": [ + "def search_matrix(matrix: list, target: int) -> bool:\n", + " \"\"\"\n", + " :type matrix: list\n", + " :type target: int\n", + " :rtype: bool\n", + " \"\"\"\n", + " for i in matrix:\n", + " for j in i:\n", + " if target < j: # 当要搜索的数字小于当前数字的时候,结束本次遍历,减少遍历次数\n", + " break\n", + " elif target == j:\n", + " return True\n", + " else:\n", + " pass\n", + " return False\n", + "\n", + "\n", + "if __name__ == '__main__':\n", + " m = [\n", + " [1, 4, 7, 11, 15],\n", + " [2, 5, 8, 12, 19],\n", + " [3, 6, 9, 16, 22],\n", + " [10, 13, 14, 17, 24],\n", + " [18, 21, 23, 26, 30]\n", + " ]\n", + " t = 5\n", + " print(search_matrix(m, t))" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CAaqRTjReGM\n", + "4fBPbYfpkAw\n", + "ydw8Au37SDk\n", + "21LGY5KbApJ\n", + "m48fWHGj3lg\n", + "rGy1NhcoPnR\n", + "gtbN2MWuQ2w\n", + "Kbm95mscXIC\n", + "uiFo0AgWvN5\n", + "IVZPQWGn0DD\n", + "k1ySa0lKN1B\n", + "TgrnuWlSoFX\n", + "GZ6fCUWZWpO\n", + "Yoiz0vqScjU\n", + "JMHp2BpafAE\n", + "AAFVkSqJMCt\n", + "S1EDKklD9ho\n", + "VoRQpMU1O45\n", + "MtIroEFYKQ5\n", + "j9ioffVEvjE\n", + "ZQI7XrIKNtw\n", + "fRaFwnm9zu6\n", + "lOGQMBPdYah\n", + "dT7PXmdb1PA\n", + "oOzEIzYMbox\n", + "DBI2kzRUBzb\n", + "B1A06SEzGzs\n", + "ntStfvFVFVW\n", + "4RBYK74dmme\n", + "3ddeqyINiG0\n", + "5a6hzTinvjR\n", + "PolxG3Y4YpA\n", + "OuCoFaGlei3\n", + "K3leJXbhF4V\n", + "zi6uF9uJvzP\n", + "rU2wJVea439\n", + "J5Zawir1zgv\n", + "QOK0tPvuYkP\n", + "4LvCUaTLwMh\n", + "vQuaymlotNN\n", + "pDFPXesC0Hl\n", + "mkBUzBOSRZt\n", + "0HbqOPloEDn\n", + "X61e9dbKqJs\n", + "OzKpCLAKXJ5\n", + "vZct2jtjgU0\n", + "Y8AhaMAlHQk\n", + "LccOJzGOshD\n", + "L0RLkfjjz85\n", + "xRUwBsk6QeF\n", + "wLGXvNdzERt\n", + "Co5hQNjLrpn\n", + "ZfhNLwuggGe\n", + "pJZwfc7xavD\n", + "k1AUkLwFx5E\n", + "PRXtJIBlGG3\n", + "FT0UPBMFGsz\n", + "Xevn5BSCtwa\n", + "I9cRg9Qujup\n", + "T91mhhX44rL\n", + "XoFSdHHri1r\n", + "OdVaZ1kapTL\n", + "u2dZl83Pyk4\n", + "kygFEXLi502\n", + "N543KU68p6L\n", + "en8apomWQd3\n", + "gHuxV1W6cul\n", + "CLfPKm5pD5n\n", + "hz9IONGHoBH\n", + "LosBkwGgdFm\n", + "ar40LEVEVUJ\n", + "vKsAZVB0mFx\n", + "zSR8KI4T1GF\n", + "Jen9cHRIANk\n", + "8N1SWMLYToL\n", + "nocyhJY4C9f\n", + "NEs8ZsGqRdR\n", + "TO60vTdR5ta\n", + "mRLKB6Rzold\n", + "t5BRTPabpjJ\n", + "ZPydZ3tAlvT\n", + "QAFKrOWrJWA\n", + "NP6BjfsyJkM\n", + "Y1ZCSatVitd\n", + "ONVgV9fhYSA\n", + "ZUVjYS9XbJz\n", + "ckF4t5NUVWn\n", + "gE6PgWsh19X\n", + "QD0VeLExuP7\n", + "KKpzQsXS2Rt\n", + "IawVu00oHY1\n", + "AZDHEqN1vt3\n", + "44MtVQBlMU3\n", + "7GpmdeL1mVm\n", + "50YFnuRci9Z\n", + "3Vp1LMFIgc5\n", + "UzOYs1qsthJ\n", + "w1EuQRrsm9X\n", + "TcTlmIfHzYj\n", + "oEAJCuDU9Gh\n", + "2JyID4Ttrrr\n", + "1u1rwdBHYVl\n", + "dQML6PlbsbG\n", + "CjRw352dKaT\n", + "OdjTLLEVjSj\n", + "YhtH89uEYh6\n", + "QMd0sEkAeZz\n", + "XTAlAHKEH0b\n", + "0He4NmLDMsk\n", + "D4dGHUj0y8n\n", + "7RGELs5z3kK\n", + "I0AUKoioBPP\n", + "4fBVRCwaKpg\n", + "dnpxmTlWghG\n", + "irfzYKNV2Y6\n", + "yoIQn8j0OMq\n", + "7XpQqfVE74k\n", + "TmLpQWYAloD\n", + "YVabpJxq2nu\n", + "k3DfIAAPO8Z\n", + "Dug9oW904Iu\n", + "U2bQtWcTJKm\n", + "VsUyOzGFsYj\n", + "8npTFuWBPXc\n", + "XerxgazfbDt\n", + "7lB4VDw3D2C\n", + "pN1S1NDSQka\n", + "zqzAyUSR4xB\n", + "xFKtbzs91Ct\n", + "6EkyzvUKIoj\n", + "VfMoJ1ZReGw\n", + "oTazhU50dK0\n", + "NWnc5ODQOBM\n", + "MMuM4PAwBuB\n", + "s4TuILgSC7d\n", + "xwVEUjTcWYP\n", + "SNS9t7UWBBg\n", + "dYVK5YuwmMT\n", + "ky62Xy7CwzC\n", + "XCNJTOafhY2\n", + "ebDoK45VWkK\n", + "Hvgk1NE2ZdD\n", + "aFMuAf0M22a\n", + "ttJfPBWSFeI\n", + "4O3HdcGj0vg\n", + "qKPkKyxiH8U\n", + "vV7VEO81kIZ\n", + "hsIEWMaAgiG\n", + "gcjs9tNu4te\n", + "uWDJzkvJ8vq\n", + "pjOxQBnrpH1\n", + "PxLkB6VgweV\n", + "akABqKXR3iF\n", + "fNUMTRraUM5\n", + "RUbkGONF4aX\n", + "e5W9GwYjoDV\n", + "GTJqw9vNsy4\n", + "n6yWQp3gGxo\n", + "8WunGI7fBHe\n", + "AI2O3DjHHpH\n", + "VL8l9OKr8My\n", + "WQVe3OZmy78\n", + "flhQ1BJLNf3\n", + "VtgL9XCqviq\n", + "dPhB3eM0QcK\n", + "n4GV3swUlIK\n", + "mkvhAgYdMKV\n", + "bvOhFFF58bA\n", + "2wOXN8NVqjQ\n", + "zWKjMMD4AH6\n", + "hpzoD8UhOLz\n", + "au2nhSlNigO\n", + "jZF2mS5GHU7\n", + "BMpRheboGUX\n", + "O15ynv5wheW\n", + "kQGOHkJ1yax\n", + "SRezxyJp5Ui\n", + "moXHyyOUOgd\n", + "IwqxQUZdZaM\n", + "ufcPwSRRDEP\n", + "DP8mpZtydof\n", + "63p4TcLzPT5\n", + "TvtNp10j2ox\n", + "NjS6XhQb6w0\n", + "FCGW6Ey29ar\n", + "6RRhzyTaCfH\n", + "maqrdBpTaiV\n", + "jjJ5yMDY3jL\n", + "bxNTaxkW7b3\n", + "vjVpuxO0kfs\n", + "88BQbPxQj5F\n", + "SnmskPDpvuR\n", + "e56sX53WrlX\n", + "80HVU0YSSRl\n", + "jV0QDl9Znbk\n", + "0gdtvFeUxhu\n", + "KtJhwdvfDtq\n", + "qO0D8wjJBNB\n", + "Co9FOo23HFz\n", + "Nj7VnIbRQ9a\n", + "mNMLSeS2z7C\n" + ] + } + ], + "source": [ + "import random\n", + "import string\n", + "\n", + "\n", + "def GenKey(length):\n", + " chars = string.ascii_letters + string.digits\n", + " return ''.join([random.choice(chars) for i in range(length)])\n", + "\n", + "\n", + "def SaveKey(content):\n", + " f = open('Result Key.txt', 'a')\n", + " f.write(content)\n", + " f.write('\\n')\n", + " f.close()\n", + "\n", + "\n", + "if __name__ == '__main__':\n", + " for i in range(200):\n", + " value = GenKey(11)\n", + " print (value)\n", + " SaveKey(value)\n", + "\n", + "chars = string.ascii_letters + string.digits\n", + "result = ''.join([random.choice(chars) for i in range(11)])\n", + "print (result)" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [], + "source": [ + "def Dirfile(srcdir ,file_ext):\n", + " filelist = []\n", + " dstlist = []\n", + " filelist.append(srcdir)\n", + " while len(filelist) != 0:\n", + " tmpdir = filelist.pop()\n", + " if os.path.isdir(tmpdir):\n", + " tmpvec = os.listdir(tmpdir)\n", + " for tmpitem in tmpvec:\n", + " filelist.append(tmpdir + \"\\\\\" + tmpitem)\n", + " else:\n", + " if os.path.isfile(tmpdir):\n", + " if os.path.splitext(tmpdir)[1] == file_ext:\n", + " dstlist.append(tmpdir)\n", + " return dstlist" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 0 0\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "\n", + "def code_lines_count(path):\n", + " code_lines = 0\n", + " comm_lines = 0\n", + " space_lines = 0\n", + " for root,dirs,files in os.walk(path):\n", + " for item in files:\n", + " file_abs_path = os.path.join(root,item)\n", + " postfix = os.path.splitext(file_abs_path)[1]\n", + " if postfix == '.py':\n", + "\n", + "\n", + " with open(file_abs_path) as fp:\n", + " while True:\n", + " line = fp.readline()\n", + " if not line:\n", + "\n", + " break\n", + " elif line.strip().startswith('#'):\n", + "\n", + " comm_lines += 1\n", + " elif line.strip().startswith(\"'''\") or line.strip().startswith('\"\"\"'):\n", + " comm_lines += 1\n", + " if line.count('\"\"\"') ==1 or line.count(\"'''\") ==1:\n", + " while True:\n", + " line = fp.readline()\n", + "\n", + " comm_lines += 1\n", + " if (\"'''\" in line) or ('\"\"\"' in line):\n", + " break\n", + " elif line.strip():\n", + "\n", + " code_lines += 1\n", + " else:\n", + "\n", + " space_lines +=1\n", + "\n", + " return code_lines,comm_lines,space_lines\n", + "\n", + "if __name__ == '__main__':\n", + " abs_dir = os.getcwd()\n", + " x,y,z = code_lines_count(abs_dir)\n", + " print(x,y,z)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.0" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} -- Gitee From b1d55a613499f00fc8e8936a7a974d4e790ee0ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E6=B0=B4=E6=9C=9B?= <1378277891@qq.com> Date: Sat, 26 Mar 2022 07:46:05 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=20homework=5F01?= =?UTF-8?q?=5Fpython/homework=20=E4=B8=BA=20homework=5F01=5Fpython/homewor?= =?UTF-8?q?k1.ipynb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- homework_01_python/{homework => homework1.ipynb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename homework_01_python/{homework => homework1.ipynb} (100%) diff --git a/homework_01_python/homework b/homework_01_python/homework1.ipynb similarity index 100% rename from homework_01_python/homework rename to homework_01_python/homework1.ipynb -- Gitee