Skip to content

Commit 5c9bdff

Browse files
committed
fix 0006 and commit 0007
1 parent 2dec509 commit 5c9bdff

File tree

5 files changed

+93
-4
lines changed

5 files changed

+93
-4
lines changed

Jimmy66/0006/0006.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@ def most_word_number(word_list):
1919
str_dict = {}
2020
for item in word_list:
2121
if item in str_dict:
22-
str_dict[item] +=1
22+
str_dict[item] += 1
2323
else:
24-
str_dict[item] =1
25-
24+
str_dict[item] = 1
25+
#非常漂亮的写法,来自于别人的代码,下面那个是我看到这个后自己写的,但是这个有一个比较奇怪的问题,在sublime中少打一行或者略作修改,保存的结果会不同,我也解释不清楚为什么
2626
str_dict = {str_dict[key]:key for key in str_dict}
2727
return (max(str_dict),str_dict[max(str_dict)])
28+
# temp = {}
29+
# for key in str_dict:
30+
# temp[str_dict[key]] = key
31+
# return max(temp),temp[max(temp)]
32+
2833

2934

3035
if __name__ == '__main__':
3136
string = file_read('GitHub.txt')
3237
words = list1(string)
33-
print (most_word_number(words))
38+
times,word = most_word_number(words)
39+
print '出现最多的单词为' + str(word) + ',出现了' + str(times) + '次'
3440

Jimmy66/0007/0007.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
#完成了一部分,还没有找出空行和注释行数
5+
6+
import os
7+
import glob
8+
9+
def get_file_list():
10+
return glob.glob('*')
11+
12+
def file_read(filename):
13+
with open(filename,'r') as fp:
14+
linelist = fp.readlines()
15+
return len(linelist)
16+
17+
if __name__ == '__main__':
18+
n1 = 0
19+
os.chdir('./code')
20+
file_list = get_file_list()
21+
for name in file_list:
22+
n1 += file_read(name)
23+
print '文件夹中的文件总行数为' + str(n1) + '行'

Jimmy66/0007/code/sketch_140913a.pde

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
void setup()
2+
{
3+
size(800,800);
4+
}
5+
void draw()
6+
{
7+
background(0);
8+
float r=random(0,mouseX);
9+
println(r);
10+
ellipse(400,400,r,r);
11+
}

Jimmy66/0007/code/sketch_140930a.pde

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
int []x={200,400};
2+
int i;
3+
void round(int a, int b){
4+
ellipse(a,b,100,100);
5+
}
6+
void setup(){
7+
size(600,600);
8+
smooth();
9+
ellipseMode(RADIUS);
10+
11+
}
12+
void draw(){
13+
background(255);
14+
/*
15+
if(mousePressed==true)
16+
{
17+
fill(0);
18+
}
19+
*/
20+
for(i=0;i<2;i++)
21+
{
22+
if(dist(mouseX,mouseY,x[i],x[i])<100) fill(255,128,0);
23+
else fill(255);
24+
round(x[i],x[i]);
25+
26+
}
27+
28+
}

Jimmy66/0007/code/sketch_141005a.pde

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
int i=0;
2+
void setup(){
3+
size(600,800);
4+
smooth();
5+
ellipseMode(RADIUS);
6+
}
7+
void draw(){
8+
i++;
9+
background(255);
10+
if(i==1) fill(255,0,0);
11+
else fill(0);
12+
ellipse(300,150,80,80);
13+
if(i==2) fill(255,255,0);
14+
else fill(0);
15+
ellipse(300,350,80,80);
16+
if(i==3) fill(0,255,0);
17+
else fill(0);
18+
ellipse(300,550,80,80);
19+
i=i%3;
20+
delay(1000);
21+
}

0 commit comments

Comments
 (0)