Skip to content

Commit 882ad23

Browse files
committed
Merge pull request Show-Me-the-Code#166 from lwhhhh/master
add no.2
2 parents 8ca57cc + 0456030 commit 882ad23

27 files changed

+1140
-0
lines changed
File renamed without changes.
File renamed without changes.

lwh/1/active_code.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
做为 Apple Store App 独立开发者,你要搞限时促销,
3+
为你的应用生成激活码(或者优惠券),
4+
使用 Python 如何生成 200 个激活码(或者优惠券)?
5+
6+
激活码格式:
7+
19个字符组成,分成4组,中间用"-"连接起来
8+
必须同时包含大小写字母数字
9+
10+
"""
11+
import random
12+
import string
13+
14+
15+
def generate_active_code():
16+
active_code = []
17+
ascii_ = string.ascii_letters + string.digits
18+
active_code = ["".join([random.choice(ascii_) for i in range(16)])
19+
for j in range(200)]
20+
print(len(active_code))
21+
return active_code
22+
23+
if __name__ == "__main__":
24+
active_code = generate_active_code()
25+
print(active_code)

lwh/2/active_code.txt

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
RXUadiI0zOKmg5Ww
2+
z4qo5vaXKGM8uFsB
3+
TU3PdPnSAKtUcXwl
4+
dy2nuUEjRczyXC0a
5+
Xn8MFsTBRCbcG45E
6+
7DmryUic3pOs1DFu
7+
REINIyXEsovPrJ2G
8+
OKTYjXVpTljHanCO
9+
SzsuRGUmL6sEXBA1
10+
FrKGmMjKQGt0ImDV
11+
BLYXVaqENcuJXfUh
12+
ydsilfQorQtLKJs4
13+
abX1AUFy61k0gPZh
14+
xjEyzBwwu9AXrAaU
15+
wuJXMMscjhUpjOu1
16+
fbVRxeWbpilOQEQ2
17+
gKnLlSMvzFup2ubi
18+
mcU54YoHxGZ3gbRy
19+
izdNk0U2nlAqN5HT
20+
zGx1bP240lai9qMG
21+
3Nqa5IB5dzuPWfBA
22+
jAtgS3XXojFlWI5j
23+
L8rb8ODGhGO03D7x
24+
1SZ5ouRlwul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
77+
sEcmFMdcvz57wBkr
78+
OYouRL6AD21NncGn
79+
aNRk1zxXhrr30fAm
80+
g40yzH8LHOOymofr
81+
oPw8MO6iNamJ1bYK
82+
QfnffjYdbE8BKCqF
83+
mbEKxuHBNHHloDy0
84+
oeVHq1yblfNbDlm2
85+
S5O9WOvWHMUU0ymx
86+
eiwlpN9GuRGmpbn0
87+
TMGHVairDKmSGbCk
88+
kiOC0MLXtctQxLe5
89+
rfoaB5W9YxwMzNki
90+
FWIoPqzYBkxWUA5n
91+
HoCqNcTtQEtjAUMP
92+
Gy6nVQJmgsgv9hGc
93+
PBTm3QAQ6jNFkvUZ
94+
j3yRTRrcFGUgDwow
95+
bPF8g0RHaN47Q4dN
96+
NzM9WIrXiDbi5IXD
97+
w54j8L5ngiakgayX
98+
hkd4g0UkVhmNnyR6
99+
iEz5VpcVi1mpS1gq
100+
KWkIIA97y42V5cnx
101+
5LZGIXk2odGvSTE1
102+
s1NdaGmS5YB8VJEL
103+
272uuYgOloY7hJ8t
104+
oc0hco4FYw75n4US
105+
DzmWY32kG7JaFG3R
106+
UIaLpcjN9yA12Uo5
107+
8RYmqxQ8IxUU0aGz
108+
D5Td2B7lEEUDYsUw
109+
vJ0rZHnIlI6sHDo5
110+
MYLBHHfax5MvUf96
111+
CQisO7bfEUwpr2Qy
112+
dyLBeumYaTAGHFyM
113+
wvFS79uJMwWSUgHv
114+
KkwuShhSHkzKy6op
115+
O72zwUdEuetJnnQ6
116+
Qj7r8dbBf1fKV55k
117+
T7K47FF9KcrEYcI7
118+
N79n066wlGUsxanD
119+
XPrc3XrLHA23mmmb
120+
sANdjXf4gD5tJvWF
121+
ARJPiZz9HmQbtqOW
122+
7WAr9oIw9sebBNWj
123+
UmKbDJ9Z3XDB0uxa
124+
XbqEHERAPrrM42ud
125+
iRMKgFM0gqr9G8Rt
126+
WfdEyO5sGxXKiYND
127+
3hPPrf7M3UPk3Pis
128+
PiL0B8e9ZtKPRsuj
129+
YuQXWQTw24RlfOUw
130+
nG8kOk3G6VWM3XcX
131+
0XblQUEM8uCl8ljl
132+
VY2AKbDNFTXT2Vpj
133+
BZkiI7LxBsSPp9wI
134+
WuCVLSQqpj2jBA74
135+
I6ASBeIdmYPxg7Zx
136+
OIAeCY1FHbOdJHnk
137+
h3r45aQva46D0MkG
138+
BlHBdOq3KqcokYnp
139+
X4mFpYkR7LgyBdf9
140+
r04TZnPIpXlrYajl
141+
Zoa59BtKi0C7N3vQ
142+
PAUVrdCcV46DMcTa
143+
XzkP2UjLVPd6UdeH
144+
tFuOwhfZAminRknq
145+
LLRXDREtywZ9oL2l
146+
1Bt1hjCu87iRvjVO
147+
843udSQ5CYhxzpY3
148+
zm78Qr1fm6YbD5Pc
149+
nkKKOAThEvmvMDck
150+
daNI9lwDGwWPXgDh
151+
3AD5vzwEgCh62OGG
152+
g0WACS40VWUhhO3n
153+
8DSPNQnnPpExp5ae
154+
1qDbOw7VXQu6sJyx
155+
IHeAepe22BqzyRYI
156+
Pyc8MoGTBonXrsig
157+
caIx6iJTzzrwRh76
158+
TuCiIBooXAtxGA1s
159+
d5vL89dwRziYYkOC
160+
Th7QNxgmuAHgdxjY
161+
Qde8adGqOCJLStgi
162+
X4YVCKnkpIglPXNH
163+
DJaSfz6ZZ5AexZrh
164+
p0suRQkjR2gPB50J
165+
Xu7zNDMf8LTXgUfP
166+
iO7lZE1d5u9C4agr
167+
ZScUrgefG4mhv7sn
168+
cxKn0LeiJmTmOncc
169+
MlHM9bSCqbLeYQyl
170+
hnNxbuM0iFXasDNU
171+
U9TDcgewoYmCuL8Z
172+
NiWuD6W6yo5naWVa
173+
6xB2tyGaP9XD1Reu
174+
MyMQgM3LVp3OOZbH
175+
GNReq9Tsm9yEkjnH
176+
wv0m9rGnQlTzWBsz
177+
VXdYlEkAdRsw74Q6
178+
KYvyofRRw4HdHdGa
179+
feOc882CM6u3Vmb9
180+
bHfFtp2xlqR9ov7Z
181+
I9WJT51PDOho07f2
182+
mbfys9pZlaBa71fn
183+
Z7B8uUPNGUolHgve
184+
CyGhoq3E5eaLuYd8
185+
Sp4zPGY0Zb4ce2kX
186+
dawy36RyxYpGlDTG
187+
gJlcfSukZBZZbOji
188+
DM5lIjwwSR5Ixta0
189+
HQIN6iSuBBu95Cy1
190+
c3JKxSbY0vqx4SEC
191+
9H4DXpc17vFjPCeE
192+
c48hIoAA5E5lVScv
193+
gadG0fAunAWg3C4I
194+
jr9kg1rr4rGPAT5i
195+
aLipX2YqYy8FyImJ
196+
GP87sr1igGhbAVnB
197+
Oghe3rzJSi4N9bCh
198+
j0pl6r1H8LD89zpg
199+
g9G0cNNlbgRRiuRM
200+
jqyltqFWJLEe0Gez

lwh/2/pymysql.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# -*- coding: utf-8 -*-
2+
3+
#!/usr/bin/python
4+
# -*- coding: UTF-8 -*-
5+
6+
import pymysql
7+
8+
9+
# 打开数据库连接
10+
db = pymysql.connect("localhost", "root", "", "")
11+
12+
# 使用cursor()方法获取操作游标
13+
cursor = db.cursor()
14+
15+
# 使用execute方法执行SQL语句
16+
cursor.execute("CREATE DATABASE IF NOT EXISTS pymysql;")
17+
cursor.execute("USE pymysql;")
18+
cursor.execute(
19+
"CREATE TABLE IF NOT EXISTS active_code(code VARCHAR(255));")
20+
21+
with open("active_code.txt", "r") as f:
22+
while True:
23+
s = f.readline().strip()
24+
# print(s)
25+
if s == "":
26+
break
27+
cursor.execute("INSERT INTO active_code (code) values(%s)", [s])
28+
29+
db.commit()
30+
#cursor.execute("USE pymsql")
31+
cursor.execute("SELECT * FROM active_code")
32+
33+
# 使用 fetchone() 方法获取一条数据库。
34+
#data = cursor.fetchone()
35+
36+
#print("Database version : %s " % data)
37+
38+
# 关闭数据库连接
39+
db.close()

lwh/4/test_doc.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
Stanford Report, June 14, 2005
2+
3+
��You��ve got to find what you love,�� Jobs says
4+
5+
This is the text of the Commencement address by Steve Jobs, CEO of Apple Computer and of Pixar Animation Studios, delivered on June 12, 2005.
6+
7+
I am honored to be with you today at your commencement from one of the finest universities in the world. I never graduated from college. Truth be told, this is the closest I��ve ever gotten to a college graduation. Today I want to tell you three stories from my life. That��s it. No big deal. Just three stories.
8+
9+
The first story is about connecting the dots.
10+
11+
I dropped out of Reed College after the first 6 months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?
12+
13+
It started before I was born. My biological mother was a young, unwed college graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife. Except that when I popped out they decided at the last minute that they really wanted a girl. So my parents, who were on a waiting list, got a call in the middle of the night asking: ��We have an unexpected baby boy; do you want him?�� They said: ��Of course.�� My biological mother later found out that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would someday go to college.
14+
15+
And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents�� savings were being spent on my college tuition. After six months, I couldn��t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life. So I decided to drop out and trust that it would all work out OK. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn��t interest me, and begin dropping in on the ones that looked interesting.
16+
17+
It wasn��t all romantic. I didn��t have a dorm room, so I slept on the floor in friends�� rooms, I returned coke bottles for the 5?? deposits to buy food with, and I would walk the 7 miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:
18+
19+
Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn��t have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can��t capture, and I found it fascinating.
20+
21+
None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the Mac would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, its likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on this calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards ten years later.
22+
23+
Again, you can��t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something �C your gut, destiny, life, karma, whatever. This approach has never let me down, and it has made all the difference in my life.
24+
25+
My second story is about love and loss.
26+
27+
I was lucky �C I found what I loved to do early in life. Woz and I started Apple in my parents garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a $2 billion company with over 4000 employees. We had just released our finest creation �C the Macintosh �C a year earlier, and I had just turned 30. And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. So at 30 I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.
28+
29+
I really didn��t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down �C that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me �C I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.
30+
31+
I didn��t see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.
32+
33+
During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the worlds first computer animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, I retuned to Apple, and the technology we developed at NeXT is at the heart of Apple��s current renaissance. And Laurene and I have a wonderful family together.
34+
35+
I��m pretty sure none of this would have happened if I hadn��t been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometimes life hits you in the head with a brick. Don��t lose faith. I��m convinced that the only thing that kept me going was that I loved what I did. You��ve got to find what you love. And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven��t found it yet, keep looking. Don��t settle. As with all matters of the heart, you��ll know when you find it. And, like any great relationship, it just gets better and better as the years roll on. So keep looking until you find it. Don��t settle.
36+
37+
My third story is about death.
38+
39+
When I was 17, I read a quote that went something like: ��If you live each day as if it was your last, someday you��ll most certainly be right.�� It made an impression on me, and since then, for the past 33 years, I have looked in the mirror every morning and asked myself: ��If today were the last day of my life, would I want to do what I am about to do today?�� And whenever the answer has been ��No�� for too many days in a row, I know I need to change something.
40+
41+
Remembering that I��ll be dead soon is the most important tool I��ve ever encountered to help me make the big choices in life. Because almost everything �C all external expectations, all pride, all fear of embarrassment or failure �C these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.
42+
43+
About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn��t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and that I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor��s code for prepare to die. It means to try to tell your kids everything you thought you��d have the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.
44+
45+
I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck an endoscope down my throat, through my stomach and into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare form of pancreatic cancer that is curable with surgery. I had the surgery and I��m fine now.
46+
47+
This was the closest I��ve been to facing death, and I hope its the closest I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept:
48+
49+
No one wants to die. Even people who want to go to heaven don��t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It is Life��s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.
50+
51+
Your time is limited, so don��t waste it living someone else��s life. Don��t be trapped by dogma �C which is living with the results of other people��s thinking. Don��t let the noise of other��s opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.
52+
53+
When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the bibles of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 1960��s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along: it was idealistic, and overflowing with neat tools and great notions.
54+
55+
Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: ��Stay Hungry. Stay Foolish.�� It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I have always wished that for myself. And now, as you graduate to begin anew, I wish that for you.
56+
57+
Stay Hungry. Stay Foolish.

lwh/4/word_counter.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import re
2+
#import collections.Counter
3+
from collections import Counter
4+
5+
with open("test_doc.txt", "r") as file_obj:
6+
7+
cont = file_obj.read()
8+
9+
# 正则匹配精准度更高.使用切片会出现无法切换行符的情况
10+
re_cont = re.compile(r"[a-zA-Z]+")
11+
word_cont = re_cont.findall(cont)
12+
cnt = Counter(word_cont)
13+
print(cnt.most_common())
14+
15+
while True:
16+
s = input("enter the key")
17+
if s == "":
18+
break
19+
print(word_dict[s])

lwh/6/import_word.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import re
3+
from collections import Counter
4+
from os.path import join, getsize
5+
6+
root_dir = os.getcwd() + "\\myrecord"
7+
8+
9+
for root, dirs, files in os.walk(root_dir):
10+
for i in files:
11+
with open(root_dir + "\\" + i, "r") as f:
12+
cont = f.read()
13+
# print(cont)
14+
re_cont = re.compile(r"[a-zA-Z]+")
15+
word_cont = re_cont.findall(cont)
16+
cnt = Counter(word_cont)
17+
print(cnt.most_common(1))

0 commit comments

Comments
 (0)