IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> Java知识库 -> 京东数科Java面试,这几个5 -> 正文阅读

[Java知识库]京东数科Java面试,这几个5

turtle.circle(30, 110)

turtle.fd(20)

turtle.left(40)

turtle.circle(90, 70)

turtle.circle(30, 150)

turtle.right(30)

turtle.fd(15)

turtle.circle(80, 90)

turtle.left(15)

turtle.fd(45)

turtle.right(165)

turtle.fd(20)

turtle.left(155)

turtle.circle(150, 80)

turtle.left(50)

turtle.circle(150, 90)

turtle.end_fill()  # 结束填充



# 右侧花瓣

turtle.left(150)

turtle.circle(-90, 70)

turtle.left(20)

turtle.circle(75, 105)

turtle.setheading(60)

turtle.circle(80, 98)

turtle.circle(-90, 40)



# 左侧花瓣

turtle.left(180)

turtle.circle(90, 40)

turtle.circle(-80, 98)

turtle.setheading(-83)



# 左侧叶子

turtle.fd(30)

turtle.left(90)

turtle.fd(25)

turtle.left(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(-80, 90)

turtle.right(90)

turtle.circle(-80, 90)

turtle.end_fill()



turtle.right(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(85)

turtle.left(90)

turtle.fd(80)



# 右侧叶子

turtle.right(90)

turtle.right(45)

turtle.fillcolor("green")

turtle.begin_fill()

turtle.circle(80, 90)

turtle.left(90)

turtle.circle(80, 90)

turtle.end_fill()



turtle.left(135)

turtle.fd(60)

turtle.left(180)

turtle.fd(60)

turtle.right(90)

turtle.circle(200, 50)  # 画一个圆 200 是半径,50 是弧度



time.sleep(1)

# turtle.tracer(False)

#turtle.pensize(3)

#turtle.speed(0)

turtle.color("red", "red")

turtle.up()

turtle.goto(-230, 50)

turtle.down()

turtle.begin_fill()

turtle.left(180)

turtle.fd(80)

turtle.circle(-40, 180)

turtle.left(90)

turtle.circle(-40, 180)

turtle.left(0)

turtle.fd(80)

turtle.end_fill()



time.sleep(1)

# turtle.tracer(False)

#turtle.pensize(3)

#turtle.speed(0)

turtle.color("red", "red")

turtle.up()

turtle.goto(-230, -80)

turtle.down()

turtle.begin_fill()

turtle.left(-30)

turtle.fd(80)

turtle.circle(-40, 180)

turtle.left(90)

turtle.circle(-40, 180)

turtle.left(0)

turtle.fd(80)

turtle.end_fill()



time.sleep(1)

# turtle.tracer(False)

# turtle.pensize(3)

# turtle.speed(0)

turtle.color("red", "red")

turtle.up()

turtle.goto(-130, -180)

turtle.down()

turtle.begin_fill()

turtle.left(-80)

turtle.fd(80)

turtle.circle(-40, 180)

turtle.left(90)

turtle.circle(-40, 180)

turtle.left(0)

turtle.fd(80)

turtle.end_fill()



time.sleep(1)

# turtle.tracer(False)

# turtle.pensize(3)

# turtle.speed(0)

turtle.color("red", "red")

turtle.up()

turtle.goto(200, -200)

turtle.down()

turtle.begin_fill()

turtle.left(-90)

turtle.fd(80)

turtle.circle(-40, 180)

turtle.left(90)

turtle.circle(-40, 180)

turtle.left(0)

turtle.fd(80)

turtle.end_fill()



time.sleep(1)

# turtle.tracer(False)

# turtle.pensize(3)

# turtle.speed(0)

turtle.color("red", "red")

turtle.up()

turtle.goto(200, 50)

turtle.down()

turtle.begin_fill()

turtle.left(90)

turtle.fd(80)

turtle.circle(-40, 180)

turtle.left(90)

turtle.circle(-40, 180)

turtle.left(0)

turtle.fd(80)

turtle.end_fill()

def figure1():

turtle.reset()

turtle.tracer(False)

rose()

yellowheart(-230, 50, 180)  # 左一

#time.sleep(2)

def figure2():

# turtle.reset()

turtle.tracer(False)

rose()

yellowheart(-230, -80, -30)     # 左二

# time.sleep(2)

def figure3():

turtle.reset()

turtle.tracer(False)

rose()

yellowheart(-130, -180, -30)    # 左三

# time.sleep(2)

def figure4():

turtle.reset()

turtle.tracer(False)

rose()

yellowheart(200, 50, 90)        # 右一

# ime.sleep(2)

def figure5():

turtle.reset()

turtle.tracer(False)

rose()

yellowheart(200, -200, -90)  # 右二

# time.sleep(2)

if name == “main”:

rose()

# figure1()

#

# yellowheart(-230, -80, -30)  # 左二

# 不让自动退出,放在程序的最后一行

# 不然画画结束后会自动退出

turtle.done()

coding:utf-8




**三、心心相印**

==========



![](https://img-blog.csdnimg.cn/20210518181311362.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



from turtle import *

from time import sleep

def go_to(x, y):

up()

goto(x, y)

down()

def small_Circle(size): # 函数用于绘制心的小圆

speed(10)

for i in range(210):

    forward(size)

    right(0.786)

def big_Circle(size): # 函数用于绘制心的大圆

speed(10)

for i in range(150):

    forward(size)

    right(0.3)

def line(size):

speed(10)

forward(51 * size)

def heart(x, y, size):

go_to(x, y)

left(150)

begin_fill()

line(size)

big_Circle(size)

small_Circle(size)

left(120)

small_Circle(size)

big_Circle(size)

line(size)

end_fill()

def main():

pensize(2)

color('red', 'pink')

getscreen().tracer(1, 0)

heart(100, 0, 0.7)

go_to(80, 70)

write("先生", font=("楷体", 18, "normal"))

setheading(0)

heart(-80, -100, 1)

go_to(-110, 15)

write("小姐", font=("宋体", 20, "normal"))

go_to(40, -80)

write("三生有幸遇见你!", move=True, align="left", font=("arial", 22, "italic"))

done()

main()




**四、粉嫩爱心**

==========



![](https://img-blog.csdnimg.cn/20210518181710894.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



‘’‘不正经爱心’’’

#coding=utf-8

import turtle

import time

def draw_circle():

for i in range(400):

    turtle.right(0.5)

    turtle.forward(1)

def draw_love():

#    turtle.color('red','darkred')

#    turtle.pensize(1)

turtle.pen(fillcolor="pink", pencolor="red", pensize=8)

turtle.speed(2000)

turtle.goto(0, 0)

turtle.begin_fill()

turtle.left(140)

turtle.forward(224)

draw_circle()

turtle.left(120)

draw_circle()

turtle.forward(224)

turtle.end_fill()

turtle.write("I Love you")

time.sleep(2)

turtle.up()

turtle.goto(150, 20)

turtle.color('black')

turtle.write('纵然万劫不复,纵然相思入骨,我待你依旧如初!', font=("微软雅黑", 18, "normal"))

time.sleep(2)

def draw_abc():

turtle.fillcolor("pink")

turtle.pencolor("red")

turtle.pensize(10)

turtle.speed(1)

turtle.up()

turtle.goto(0, -50)

turtle.down()

turtle.begin_fill()

turtle.circle(45)

turtle.end_fill()

time.sleep(2)

def word():

turtle.up()

turtle.goto(-100, 200)

turtle.color("red")

turtle.pensize(4)

#   turtle.down()

turtle.write('宝贝,5.20快乐!', font=("隶书", 18, "bold"))

time.sleep(10)

draw_love()

draw_abc()

word()




**五、丘比特一键穿心**

=============



![](https://img-blog.csdnimg.cn/20210518181818906.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**程序代码:**



import turtle as t

t.color(‘red’,‘pink’)

t.begin_fill()

t.width(5)

t.left(135)

t.fd(100)

t.right(180)

t.circle(50,-180)

t.left(90)

t.circle(50,-180)

t.right(180)

t.fd(100)

t.pu()

t.goto(50,-30)

t.pd()

t.right(90)

t.fd(100)

t.right(180)

t.circle(50,-180)

t.left(90)

t.circle(50,-180)

t.right(180)

t.fd(100)

t.end_fill()

t.hideturtle()

t.pu()

t.goto(250,-70)

t.pd()

t.color(‘black’)

t.width(5)

t.left(70)

t.fd(50)

t.fd(-50)

t.left(70)

t.fd(50)

t.fd(-50)

t.left(145)

t.fd(20)

t.left(145)

t.fd(50)

t.fd(-50)

t.left(70)

t.fd(50)

t.fd(-50)

t.left(145)

t.fd(20)

t.left(145)

t.fd(50)

t.fd(-50)

t.left(70)

t.fd(50)

t.fd(-50)

t.left(145)

t.width(3)

t.fd(220)

t.right(90)

t.pu()

t.fd(10)

t.pd()

t.left(90)

t.circle(10,180)

t.circle(10,-90)

t.right(90)

t.fd(-10)

t.pu()

t.fd(90)

t.left(90)

t.fd(10)

t.left(90)

t.pd()

t.circle(10,180)

t.circle(10,-90)

t.left(90)

t.fd(100)

t.begin_fill()

t.left(30)

t.fd(15)

t.right(35)

t.fd(50)

t.right(150)

t.fd(50)

t.right(62)

t.fd(25)

t.end_fill()

t.done()




**六、发射爱心小人**

============



![](https://img-blog.csdnimg.cn/20210518181410907.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



2.14

from turtle import *

from time import sleep

def go_to(x, y):

up()

goto(x, y)

down()

def head(x, y, r):

go_to(x, y)

speed(1)

circle(r)

leg(x, y)

def leg(x, y):

right(90)

forward(180)

right(30)

forward(100)

left(120)

go_to(x, y - 180)

forward(100)

right(120)

forward(100)

left(120)

hand(x, y)

def hand(x, y):

go_to(x, y - 60)

forward(100)

left(60)

forward(100)

go_to(x, y - 90)

right(60)

forward(100)

right(60)

forward(100)

left(60)

eye(x, y)

def eye(x, y):

go_to(x - 50, y + 130)

right(90)

forward(50)

go_to(x + 40, y + 130)

forward(50)

left(90)

def big_Circle(size):

speed(20)

for i in range(150):

    forward(size)

    right(0.3)

def line(size):

speed(1)

forward(51 * size)

def small_Circle(size):

speed(10)

for i in range(210):

    forward(size)

    right(0.786)

def heart(x, y, size):

go_to(x, y)

left(150)

begin_fill()

line(size)

big_Circle(size)

small_Circle(size)

left(120)

small_Circle(size)

big_Circle(size)

line(size)

end_fill()

def main():

pensize(2)

color('red', 'pink')

head(-120, 100, 100)

heart(250, -80, 1)

go_to(200, -300)

write("To: 送给智慧与美貌并存的小仙女!", move=True, align="left", font=("楷体", 20, "normal"))

done()

main()




**七、浪漫动态樱花树**

=============



![](https://img-blog.csdnimg.cn/20210518181506372.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



import turtle as T

import random

import time

画樱花的躯干(60,t)

def Tree(branch, t):

time.sleep(0.0005)

if branch > 3:

    if 8 <= branch <= 12:

        if random.randint(0, 2) == 0:

            t.color('snow')  # 白

        else:

            t.color('lightcoral')  # 淡珊瑚色

        t.pensize(branch / 3)

    elif branch < 8:

        if random.randint(0, 1) == 0:

            t.color('snow')

        else:

            t.color('lightcoral')  # 淡珊瑚色

        t.pensize(branch / 2)

    else:

        t.color('sienna')  # 赭(zhě)色

        t.pensize(branch / 10)  # 6

    t.forward(branch)

    a = 1.5 * random.random()

    t.right(20 * a)

    b = 1.5 * random.random()

    Tree(branch - 10 * b, t)

    t.left(40 * a)

    Tree(branch - 10 * b, t)

    t.right(20 * a)

    t.up()

    t.backward(branch)

    t.down()

掉落的花瓣

def Petal(m, t):

for i in range(m):

    a = 200 - 400 * random.random()

    b = 10 - 20 * random.random()

    t.up()

    t.forward(b)

    t.left(90)

    t.forward(a)

    t.down()

    t.color('lightcoral')  # 淡珊瑚色

    t.circle(1)

    t.up()

    t.backward(a)

    t.right(90)

    t.backward(b)

绘图区域

t = T.Turtle()

画布大小

w = T.Screen()

t.hideturtle() # 隐藏画笔

t.getscreen().tracer(5, 0)

w.screensize(bg=‘wheat’) # wheat小麦

t.left(90)

t.up()

t.backward(150)

t.down()

t.color(‘sienna’)

画樱花的躯干

Tree(60, t)

掉落的花瓣

Petal(200, t)

w.exitonclick()




**八、专属心形词云**

============



![](https://img-blog.csdnimg.cn/20210518181915631.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



from wordcloud import WordCloud

import PIL.Image as image

import numpy as np

import jieba

分词

def trans_CN(text):

# 接收分词的字符串

word_list = jieba.cut(text)

# 分词后在单独个体之间加上空格

result = " ".join(word_list)

return result

要读取的txt文本

with open(“love.txt”, encoding=“utf-8”) as fp:

text = fp.read()

# print(text)

# 将读取的中文文档进行分词

text = trans_CN(text)

mask = np.array(image.open("love.png"))     #添加心形图片

wordcloud = WordCloud(

    # 添加遮罩层

    mask=mask,

    # 生成中文字的字体,必须要加,不然看不到中文

    font_path="C:\Windows\Fonts\STXINGKA.TTF"

).generate(text)

image_produce = wordcloud.to_image()

image_produce.show()



**九、女朋友画像字符画**

==============



![](https://img-blog.csdnimg.cn/20210518182307248.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NDk4NTg4MA==,size_16,color_FFFFFF,t_70)



**实现代码:**



#-- coding=utf-8 --

from PIL import Image

IMG = ‘ym.jpg’ #设置图片文件

WIDTH = 150 #设置字符画的宽

HEIGHT = 80 #设置字符画的高

OUTPUT = ‘ym.txt’ #设置存放字符画的文本文件

ascii_char = list("$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/|()1{}[]?-_+~<>i!lI;:,"^`’. ") #设置显示的字符集

#将256灰度映射到70个字符上

def get_char(r,g,b,alpha = 256):

#alpha为透明度

# 判断 alpha 值,为0表示全透明

if alpha == 0:

    return ' '



# 获取字符集的长度,这里为 70

length = len(ascii_char)

# 将 RGB 值转为灰度值 gray,灰度值范围为 0-255

gray = int(0.2126 * r + 0.7152 * g + 0.0722 * b)



# 灰度值范围为 0-255,而字符集只有 70

# 需要进行如下处理才能将灰度值映射到指定的字符上

#防止当灰度值为255时,输出的第70个字符超出列表索引,所以需要将(255+1)

unit = (255.0 + 1)/length



# 返回灰度值对应的字符

return ascii_char[int(gray/unit)]

if name == ‘main’:

# 打开并调整图片的宽和高
  Java知识库 最新文章
计算距离春节还有多长时间
系统开发系列 之WebService(spring框架+ma
springBoot+Cache(自定义有效时间配置)
SpringBoot整合mybatis实现增删改查、分页查
spring教程
SpringBoot+Vue实现美食交流网站的设计与实
虚拟机内存结构以及虚拟机中销毁和新建对象
SpringMVC---原理
小李同学: Java如何按多个字段分组
打印票据--java
上一篇文章           查看所有文章
加:2021-08-11 12:06:27  更:2021-08-11 12:13:25 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/27 12:46:19-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码