From 73c84c7e113fcbd8e98f87e68451b511a0885be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E5=98=89=E6=80=A1?= <2509165002@student.example.com> Date: Thu, 16 Apr 2026 15:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .py.txt | 7 +++++++ import numpy as np.py | 10 ++++++++++ import numpy as np3.py | 17 +++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 .py.txt create mode 100644 import numpy as np.py create mode 100644 import numpy as np3.py diff --git a/.py.txt b/.py.txt new file mode 100644 index 0000000..910493d --- /dev/null +++ b/.py.txt @@ -0,0 +1,7 @@ +import numpy as np +img = np.array([ + [255, 255, 0, 0 ], + [255, 255, 0, 0 ], + [0, 0, 255, 255], + [0, 0, 255, 255] +], dtype=np.uint8) \ No newline at end of file diff --git a/import numpy as np.py b/import numpy as np.py new file mode 100644 index 0000000..8f27e5c --- /dev/null +++ b/import numpy as np.py @@ -0,0 +1,10 @@ +import numpy as np + +image = np.array([ + [100, 150, 200], + [80, 120, 180], + [60, 90, 140] +], dtype=np.uint8) + +print("原图:") +print(image) diff --git a/import numpy as np3.py b/import numpy as np3.py new file mode 100644 index 0000000..ce4f320 --- /dev/null +++ b/import numpy as np3.py @@ -0,0 +1,17 @@ +import numpy as np +vocab = ["Python", "学习", "数据", "人工智能", "编程"] +doc1 = "Python学习编程" +doc2 = "Python人工智能数据" + +def text_to_vector(text, vocab): + words = text.split() + vector = np.zeros(len(vocab)) + for i, word in enumerate(vocab): + vector[i] = words.count(word) + return vector + +v1 = text_to_vector(doc1, vocab) +v2 = text_to_vector(doc2, vocab) + +print("doc1向量:", v1) +print("doc2向量:", v2) \ No newline at end of file