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