File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments