www.rtmj.net > python画小黄人源代码

python画小黄人源代码

import turtledef getPosition(x, y): turtle.setx(x) turtle.sety(y) print(x, y)class Pikachu: def __init__(self): self.t = turtle.Turtle() t = self.t t.pensize(3) t.speed(9) t.ondrag(getPosition)def noTrace_goto(self, x, y): self.t.penup() self.t.goto(x, y) self.t.pendown()

if(s_arc[len(s_arc)-1:len(s_arc)]!='!'): s_arc+=' / '判断s_strc最后一位是不是'!',如果不是在末尾加上字符' / '如下代码实现比较简单.if(s_arc[-1] != '!'): s_arc+=' / '

import os def RemoveFileInFolder(path,filename): for filelist in os.listdir(path): filepath = os.path.join(path,filelist) if os.path.isdir(filepath): RemoveFileInFolder(filepath,filename) elif 0 == cmp(filelist,filename): os.remove(filepath)

python2 使用s=raw_input(('do you want to know the exam period for the particular semester?') python3 使用s=input(('do you want to know the exam period for the particular semester?')

def gener(n): i = 0; while i i +=1 print ''.join([str(k) for k in range(i)]) gener(5) 再看看别人怎么说的.

k=0 for i in range(4): for j in range(i+1): k=k+1 print(k*2,' ',end='') print() a=0 i=0 list1=[] while i i=i+1 a=a+i list1.append(a) print(list1) print(list1[23]-list1[21])

import itertools#集合myset中的n个元素相互组合 def get_one_subset(myset,n): return itertools.combinations(myset,n) def get_all_subset(mst): for i in range(1,len(mst)): sub_set=set() sub_set=sub_set|set(get_one_subset(mst,i)) yield sub_

#!/usr/bin/env pythonlist1 = [1,2,3]list2 = [0,1,2,3]result = []for i in list1: for j in list2: temp = i*j result.append(temp)print result

用什么?tkinter、pyQt、GTK、wxPython都可以写

printf("%d %d",++i,i++); 这个应该先算i++ 后算++i 先算的内个先提取i为0 再自加1 后面那个再自加1后提取i为2

网站地图

All rights reserved Powered by www.rtmj.net

copyright ©right 2010-2021。
www.rtmj.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com