Python画笑脸(python做简单的笑脸的编程)
怎么用python的turtle库画出这个图案,要代码?
import turtle as t
def quad(color):
? t.begin_fill()
??t.color(color)
??t.forward(100)
??t.left(36)
??t.forward(100)
??t.left(36*4)
??t.forward(100)
??t.left(36)
??t.forward(100)
??t.end_fill()
??t.left(36*3)
for i in range(10):
??if i%2:
??? ??quad('#99c8de')
??else:
??? ??quad('#e5b9c4')
两三年没碰海龟了,觉得没啥用,看你赏金又提了就回去学了学
Python语言画图
1)首先Python画图与WING IDE无关,最简单的是使用Tkinter画图
2)画出单词有很多方法,最笨的是用划线方式一笔一笔的画。其次是直接输出文本,但意义不大。另外一种方法是调用图片,你可以在图片上任意画好东西后显示出来。
3)代码示例:(这个例子就画了个简单的字母P)
from Tkinter import *
root=Tk()
root.title('Drawing Example')
canvas=Canvas(root,width=200,height=160,bg='white')
canvas.create_line(10,10,100,70)
canvas.create_line(10,10,40,10)
canvas.create_line(40,10,40,40)
canvas.create_line(10,40,40,40)
canvas.pack()
root.mainloop()
求一个python编写一个类的代码
一个用字符展示表情的类,传入参数次数,可使用方法smile, dizzy, peace, greedy, nerd
这个里面代码都没空格,请自行加空格或分隔符
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
class code_emoji():
def __init__(self, n):
self.number = n
self.code = [94, 95, 118, 62, 60, 39, 36]
def __str__(self):
return 'this is just a code emoji class!'
def __order(self, func):
func = getattr(func, '__name__')
if func == "smile":
return [self.code[0], self.code[1], self.code[0]]
elif func == "peace":
return [self.code[2], self.code[1], self.code[2]]
elif func == "dizzy":
return [self.code[3], self.code[1], self.code[4]]
elif func == "greedy":
return [self.code[-1], self.code[1], self.code[-1]]
elif func == "nerd":
return [self.code[-2], self.code[1], self.code[-2]]
def smile(self):
print "\n笑脸"
for i in xrange(self.number):
print "".join([chr(i) for i in self.__order(self.smile)])
def dizzy(self):
print "\n晕"
for i in xrange(self.number):
print "".join([chr(i) for i in self.__order(self.dizzy)])
def peace(self):
print "\n平静"
for i in xrange(self.number):
print "".join([chr(i) for i in self.__order(self.peace)])
def greedy(self):
print "\n贪婪"
for i in xrange(self.number):
print "".join([chr(i) for i in self.__order(self.greedy)])
def nerd(self):
print "\n毫无波动"
for i in xrange(self.number):
print "".join([chr(i) for i in self.__order(self.nerd)])
if __name__ == '__main__':
a = code_emoji(2)
a.smile()
a.dizzy()
a.peace()
a.greedy()
a.nerd()
程序运行结果:
C:\Python27\python.exe G:/windows_code/python/threat/just_test.py
笑脸
^_^
^_^
晕
_
_
平静
v_v
v_v
贪婪
$_$
$_$
毫无波动
'_'
'_'
Process finished with exit code 0
怎么用python中的海龟作图画一个蔡徐坤
用python中的海龟作图画一个蔡徐坤的步骤为:
1、打开python中的海龟作图。
2、先勾勒出蔡徐坤的外形线条。
3、然后编写代码填充颜色即可。