Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65621ae

Browse files
solved 28
1 parent2c55790 commit65621ae

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

‎28.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
importdownload_file
2+
3+
fromPILimportImage
4+
5+
6+
defmain():
7+
url="http://www.pythonchallenge.com/pc/ring/bell.png"
8+
file_path="ring/bell.png"
9+
username="repeat"
10+
password="switch"
11+
# first_step(url, file_path, username, password)
12+
second_step(file_path)
13+
14+
15+
deffirst_step(url,file_path,username,password):
16+
download_file.download_with_auth(url,file_path,username,password)
17+
18+
19+
defsecond_step(file_path):
20+
im=Image.open(file_path)
21+
green_channel=1
22+
green_data=im.getdata(green_channel)
23+
datas=list(green_data)
24+
datas_len=len(datas)
25+
assertdatas_len%2==0
26+
message=""
27+
foriinrange(int(datas_len/2)):
28+
index=2*i
29+
left=datas[index]
30+
right=datas[index+1]
31+
abs_left_min_right=abs(left-right)
32+
ifabs_left_min_right!=42:
33+
message+=chr(abs_left_min_right)
34+
print(message)
35+
36+
37+
if__name__=="__main__":
38+
main()

‎README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
#pythonchallenge
22
Solve Problems inhttp://www.pythonchallenge.com
33

4+
####28
5+
result:http://www.pythonchallenge.com/pc/ring/guido.html
6+
- use image.split() to split RGB channels
7+
- im.bands() return number of im's channels
8+
- ring means "green" if you visit "green.html" will get response "yes"
9+
- whodunnit is an word means "who is the murderer"
10+
11+
412
####27
513
result:http://www.pythonchallenge.com/pc/ring/bell.html auth=(repeat, switch)
614
- author use python2 keyword, but there is some different with python3

‎ring/bell.png

654 KB
Loading

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp