Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
level3-lesson23-diy2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4a5b46a3
authored
Mar 17, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
fa601d68
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4 additions
and
18 deletions
my_cloud.py
my_csv.py
mycloud.png
scores.csv
my_cloud.py
View file @
4a5b46a3
import
wordcloud
import
wordcloud
from
PIL
import
Image
import
numpy
import
jieba
with
open
(
'python二级考试大纲.txt'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
'python二级考试大纲.txt'
,
encoding
=
'utf-8'
)
as
f
:
text
=
f
.
read
()
text
=
f
.
read
()
text_list
=
jieba
.
lcut
(
text
)
w
=
wordcloud
.
WordCloud
(
background_color
=
'white'
,
font_path
=
"Simhei.ttf"
)
text
=
""
.
join
(
text_list
)
img
=
Image
.
open
(
"bell.png"
)
data
=
numpy
.
array
(
img
)
img_colors
=
wordcloud
.
ImageColorGenerator
(
data
)
stopwords
=
[
"的"
,
"python"
,
"基本"
,
"和"
,
"程序"
]
w
=
wordcloud
.
WordCloud
(
background_color
=
'white'
,
font_path
=
"SimHei.ttf"
,
mask
=
data
,
color_func
=
img_colors
,
stopwords
=
stopwords
,
max_font_size
=
60
)
w
.
generate
(
text
)
w
.
generate
(
text
)
w
.
to_file
(
"mycloud.png"
)
w
.
to_file
(
'mycloud.png'
)
my_csv.py
View file @
4a5b46a3
...
@@ -6,3 +6,5 @@ data = [["姓名", "语文", "数学", "英语"],
...
@@ -6,3 +6,5 @@ data = [["姓名", "语文", "数学", "英语"],
with
open
(
"scores.csv"
,
"w"
,
encoding
=
"UTF-8"
,
newline
=
''
)
as
csvfile
:
with
open
(
"scores.csv"
,
"w"
,
encoding
=
"UTF-8"
,
newline
=
''
)
as
csvfile
:
writer
=
csv
.
writer
(
csvfile
)
writer
=
csv
.
writer
(
csvfile
)
writer
.
writerows
(
data
)
writer
.
writerows
(
data
)
import
wordcloud
from
PIL
import
Image
mycloud.png
View file @
4a5b46a3
223 KB
|
W:
|
H:
75.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
scores.csv
deleted
100644 → 0
View file @
fa601d68
import wordcloud
with open('python二级考试大纲.txt',encoding='utf-8') as f:
text=f.read()
w=wordcloud.Wordcloud(background_color='white',font_path="SimHei.ttf")
w.generate(text)
w.to_file("mycloud.png")
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment