🍊 Java學習:Java從入門到精通總結
🍊 Spring系列推薦:Spring原始碼決議
📆 最近更新:2021年12月16日
🍊 個人簡介:通信工程本碩💪、阿里新晉猿同學🌕,我的故事充滿機遇、挑戰與翻盤,歡迎關注作者來共飲一杯雞湯
🍊 點贊 👍 收藏 ?留言 📝 都是我最大的動力!
圣誕樹
首先需要安裝python環境,如果是新手建議Google一下,實在不行也可以百度一下,很容易,另外我是用的是Python 3.6的版本,先上一個效果圖:

代碼如下,其實只有不到10行,是不是簡單到飛起?
from wordcloud import WordCloud
import PIL.Image as image
import numpy as np
with open('./christmas.txt', 'r') as f:
text = f.read()
mask = np.array(image.open('./png.png'))
word_cloud = WordCloud(mask=mask).generate(str(text))
image_file = word_cloud.to_image()
image_file.show()
此外,運行此程式需要安裝WordCloud環境,在控制臺輸入:
pip install WordCloud
即可
其中我用到的辭海txt檔案和圖片檔案我放在云盤里了,歡迎大家下載(如果覺得麻煩的話,大家也可以創建一個txt檔案,里面輸上一些英文字母,再找一張圣誕樹的照片即可!!):
圣誕樹代碼,點擊鏈接保存
平安果
平安果是用前端代碼實作的,完成后是一個.html檔案,右鍵使用瀏覽器打開就可以了,非常方便,拿去發給你最愛的人吧~愿各位同學圣誕節快樂,嘿嘿
先上一個效果圖:

代碼也特別簡單,就是html + css的前端語法:
<!DOCTYPE html>
<html>
<head>
<title>蘋果</title>
<style type="text/css">
.a{
background-color: red;
border-radius: 70% 70% 50% 50%;
width: 300px;
height: 300px;
position:relative;
margin: 0 auto;
z-index: 1;
}
.b{
background-color:red;
border-radius: 70% 70% 50% 50%;
width: 300px;
height: 300px;
position:absolute;
left:50%;
z-index: 1;
}
.c{
background-color: red;
border-radius: 50% 50% 50% 70%;
width: 300px;
height: 300px;
position:absolute;
top:30%;
z-index: 1;
}
.d{
background-color: red;
border-radius: 50% 50% 70% 50%;
width: 300px;
height: 300px;
position:absolute;
top:30%;
left:50%;
z-index: 1;
}
.e{
background-color: red;
border-radius: 50% 50% 50% 50%;
width: 360px;
height: 360px;
position:absolute;
top:4%;
right:-18%;
z-index: 1;
}
.f{
background-color: red;
border-radius: 50% 50% 50% 50%;
width: 350px;
height: 350px;
position:absolute;
top:10%;
left:35%;
z-index: 1;
}
.h{
background-color: green;
border-radius: 0% 100% 0% 100%;
width: 150px;
height: 160px;
margin: 0 auto;
position:relative;
left:8%;
top:10%;
z-index: 1;
transform: rotate(90deg);
}
</style>
</head>
<body>
<h1 align="center">Happy Christmas Eve</h1>
<div class="h"></div>
<div class="a">
<div class="b"></div>
<div class="c"></div>
<div class="d"></div>
<div class="e"></div>
<div class="f"></div>
</div>
</body>
</html>
最后大家覺得有幫助的話,歡迎關注我哦~你們的支持是我最大的動力!
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/382869.html
標籤:java
