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

Commit 7cd5776

Browse files
committed
Python why
1 parent db159e6 commit 7cd5776

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

‎taiyangxue/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [dice](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/dice) : 做硬核老爸,我用 Python
1616
- [python39](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/python39) : 你在享受十一长假时,Python 已悄悄地变了
1717
- [matrix](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/matrix) : Python 世界的黑客帝国
18+
- [why](https://github.com/JustDoPython/python-examples/tree/master/taiyangxue/why) : 练那么多,为啥还不会编程
1819

1920
---
2021

‎taiyangxue/why/app.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def sum_of_word(word):
2+
sum = 0
3+
for char in word:
4+
sum += ord(char) - 96 # 为什么需要减去 96
5+
return sum
6+
7+
with open('results.txt', 'w') as result:
8+
with open('words_alpha.txt', 'r') as file:
9+
for word in file.readlines():
10+
if sum_of_word(word.strip()) == 100: # 注意这里的 strip
11+
result.write(word)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /