python如何实现生日快乐代码


本文摘自php中文网,作者coldplay.xixi,侵删。

python实现生日快乐代码的方法:首先要按【CTRL+R】键,cmd进入命令行,输入pip install turtle安装第三方库;然后打开python IDE,将相关代码复制进去;最后按快捷键F5进行保存且执行即可。

python实现生日快乐代码的方法:

1、首先要CTRL+R然后cmd进入命令行,输入pip install turtle安装第三方库

2、打开python IDE,如下图,点击“File",选择”New File"

70b86a7545e0c502baa324825739407.png

3、复制代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

#HappyBirthday

import turtle

import time

def move(angle,length):

    turtle.penup()

    turtle.seth(angle)

    turtle.fd(length)

#prepare

turtle.setup(1000,400,100,100)

turtle.penup()

turtle.fd(-350)

turtle.seth(90)

turtle.fd(50)

turtle.pendown()

turtle.pensize(10)

turtle.pencolor("green")

turtle.seth(0)

turtle.hideturtle()

turtle.speed(5)

#呀

turtle.fd(100)

#生

turtle.pencolor("green")

turtle.circle(50,90)

turtle.circle(50,-30)

turtle.seth(0)

turtle.fd(100)

turtle.fd(-50)

turtle.left(90)

turtle.fd(30)

turtle.fd(-60)

turtle.left(90)

turtle.fd(50)

turtle.fd(-100)

turtle.fd(50)

turtle.left(90)

turtle.fd(50)

turtle.right(90)

turtle.fd(60)

turtle.fd(-120)

#日

turtle.penup()

turtle.fd(-30)

turtle.pendown()

turtle.seth(90)

turtle.fd(100)

turtle.seth(0)

turtle.fd(70)

turtle.seth(-90)

turtle.fd(50)

turtle.seth(180)

turtle.fd(70)

turtle.seth(-90)

turtle.fd(50)

turtle.seth(0)

turtle.fd(70)

turtle.seth(90)

turtle.fd(50)

#移动

move(0,30)

#快

turtle.pensize(8)

turtle.circle(30,15)

turtle.pendown()

turtle.circle(30,60)

turtle.penup()

turtle.seth(0)

turtle.fd(13)

turtle.seth(90)

turtle.pendown()

turtle.fd(40)

turtle.fd(-50)

turtle.penup()

turtle.seth(0)

turtle.fd(13)

turtle.pendown()

turtle.seth(-180)

turtle.circle(20,-90)

turtle.circle(20,90)

turtle.penup()

turtle.fd(13)

turtle.pendown()

turtle.seth(-90)

turtle.fd(60)

move(0,40)

move(90,80)

turtle.pendown()

turtle.seth(0)

turtle.fd(30)

turtle.seth(90)

turtle.fd(30)

turtle.fd(-30)

turtle.seth(0)

turtle.fd(20)

turtle.seth(-90)

turtle.fd(35)

turtle.seth(0)

turtle.fd(10)

turtle.fd(-30)

turtle.seth(90)

turtle.fd(35)

turtle.fd(-35)

turtle.seth(0)

turtle.fd(-25)

move(-90,50)

move(180,25)

turtle.pendown()

turtle.seth(0)

turtle.penup()

turtle.circle(50,20)

turtle.pendown()

turtle.circle(50,70)

turtle.seth(-90)

turtle.circle(50,60)

#移动

move(0,50)

move(90,45)

#乐

turtle.pensize(10)

turtle.pendown()

turtle.fd(40)

turtle.seth(0)

turtle.circle(50,60)

turtle.circle(50,-25)

move(-90,15)

turtle.pendown()

turtle.fd(30)

turtle.seth(0)

turtle.fd(-25)

turtle.fd(65)

turtle.fd(-40)

turtle.seth(-90)

turtle.fd(60)

turtle.seth(135)

turtle.fd(20)

move(135,10)

turtle.pendown()

turtle.seth(-135)

turtle.fd(20)

move(0,70)

turtle.pendown()

turtle.seth(135)

turtle.fd(20)

4、按快捷键F5进行保存且执行,最终效果图如下:

27804f0222200aeef15721c56b369cc.png

相关免费学习推荐:python视频教程

以上就是python如何实现生日快乐代码的详细内容,更多文章请关注木庄网络博客!!

相关阅读 >>

Python中关于装饰器级连的示例

Python人工智能是什么意思

Python自带numpy吗

Python内置的pickle库的对象序列化与反序列化

Python使用paramiko连接远程服务器执行命令的示例代码

pip 只能安装Python库吗

Python装饰器以什么开头

Python difflib模块详解

Python中子类如何调用父类函数的代码示例

Python中map()函数的方法示例

更多相关阅读请进入《Python》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...