代码改变世界

期末综合大作业:词频统计

2018-06-20 21:11 by 陈俊宇A, 160 阅读, 0 推荐, 收藏, 编辑
摘要:f=open('z.txt',mode='r',encoding='utf-8') fText=f.read() f.close() replacelist=['?' ',' '.' ';' "'" '!''\n','\ufeff'] for c in replacelist: fText=fText.replace(c,' ') fText=fText.replace(' ' 阅读全文

z

2018-06-13 21:44 by 陈俊宇A, 135 阅读, 0 推荐, 收藏, 编辑
摘要:fext=open('z.txt',mode='r',encoding='utf-8') fText=fext.read() fext.close() replacelist=['?' ',' '.' ';' "'" '!''\n','\ufeff'] for c in replacelist: fText=fText.replace(c,' ') print(fText) f... 阅读全文

递归,汉诺塔游戏

2018-06-13 21:01 by 陈俊宇A, 156 阅读, 0 推荐, 收藏, 编辑
摘要:def hanoi(n,a,b,c): if n==1: print(n,a+'->'+c) else: hanoi(n-1,a,c,b) print(n,a+'->'+c) hanoi(n-1,b,a,c) hanoi(3,'A','B','C') 阅读全文

列表、元组、字典、集合的定义、操作与综合练习

2018-06-06 21:22 by 陈俊宇A, 147 阅读, 0 推荐, 收藏, 编辑
摘要:l=['A','B','C'] t={'A','B','C'} l.append('B') print(l) scores=[66,77,88] d={'A':66,'B':77,'C':88} d['B']=99 d['D']=111 d.pop('C') print(d) s1={'A','B' 阅读全文

文件操作,列表实例NiceHexSpiral

2018-05-30 20:53 by 陈俊宇A, 183 阅读, 0 推荐, 收藏, 编辑
摘要:import turtle turtle. speed(10) colors = ['purple','yellow','red','green','blue','orange'] for i in range(200): turtle.pencolor(colors[i% 6]) turtle.forward(i) turtle.right(59) turtle.d... 阅读全文

字符串操作

2018-05-23 21:21 by 陈俊宇A, 166 阅读, 0 推荐, 收藏, 编辑
摘要:id='441900199908060015' sex=id[-2] print('性别') if (int(sex)%2==0): print('gril') else: print('boy') for i in range (12): print(9800+i,chr(9800+i)) b = input('明文') for c in b: ... 阅读全文

函数定义与使用,字符串类型2

2018-05-16 21:35 by 陈俊宇A, 224 阅读, 0 推荐, 收藏, 编辑
摘要:import turtle turtle.setup(600,400,0,0) turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolor('yellow') def mygoto(x,y): turtle.penup() turtle.goto(x,y) turtle.pendown() ... 阅读全文

函数定义与使用,字符串类型

2018-05-16 21:30 by 陈俊宇A, 274 阅读, 0 推荐, 收藏, 编辑
摘要:stuNum='201709080036' print('年级是:'+stuNum[0:4]) print('专业编号是:'+stuNum[4:9]) print('序号是:'+stuNum[-3:]) IDNo='441900199908060015' print('省市'+IDNo[0:2]) 阅读全文

函数定义与使用

2018-05-16 20:47 by 陈俊宇A, 110 阅读, 0 推荐, 收藏, 编辑
摘要:import turtle turtle.setup(600,400,0,0) turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolor('yellow') def mygoto(x,y): turtle.penup() turtle 阅读全文

for循环:用turtle画一颗五角星

2018-05-09 20:48 by 陈俊宇A, 186 阅读, 0 推荐, 收藏, 编辑
摘要:import turtle turtle.bgcolor('red') turtle.color('yellow') turtle.fillcolor('yellow') turtle.begin_fill() for i in range(5): turtle.forward(100) turtl 阅读全文