From bb7ec85b00c8d76389c73136f20339718a64dce2 Mon Sep 17 00:00:00 2001 From: monkey-soft Date: Fri, 1 Sep 2017 20:26:09 +0800 Subject: [PATCH] add 0008 add 0009 add 0014 add 0015 add 0016 --- ...development platform \302\267 GitHub.html" | 757 ++++++++++++++++++ monkey/0008/main.py | 27 + ...development platform \302\267 GitHub.html" | 757 ++++++++++++++++++ monkey/0009/main.py | 29 + monkey/0014/main.py | 56 ++ monkey/0014/student.txt | 5 + monkey/0014/student.xls | Bin 0 -> 5632 bytes monkey/0015/city.txt | 5 + monkey/0015/city.xls | Bin 0 -> 5632 bytes monkey/0015/main.py | 54 ++ monkey/0016/main.py | 55 ++ monkey/0016/numbers.txt | 5 + monkey/0016/numbers.xls | Bin 0 -> 5632 bytes 13 files changed, 1750 insertions(+) create mode 100644 "monkey/0008/The world's leading software development platform \302\267 GitHub.html" create mode 100644 monkey/0008/main.py create mode 100644 "monkey/0009/The world's leading software development platform \302\267 GitHub.html" create mode 100644 monkey/0009/main.py create mode 100644 monkey/0014/main.py create mode 100644 monkey/0014/student.txt create mode 100644 monkey/0014/student.xls create mode 100644 monkey/0015/city.txt create mode 100644 monkey/0015/city.xls create mode 100644 monkey/0015/main.py create mode 100644 monkey/0016/main.py create mode 100644 monkey/0016/numbers.txt create mode 100644 monkey/0016/numbers.xls diff --git "a/monkey/0008/The world's leading software development platform \302\267 GitHub.html" "b/monkey/0008/The world's leading software development platform \302\267 GitHub.html" new file mode 100644 index 00000000..4e6348b9 --- /dev/null +++ "b/monkey/0008/The world's leading software development platform \302\267 GitHub.html" @@ -0,0 +1,757 @@ + + + + + + + + + + + + + + + + + + + + + + + + The world's leading software development platform · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content +
+ + + + + + + + + + +
+ +
+ +
+
+ + + +
+ + +
+
+
+
+

Built for developers

+

+ GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside millions of other developers. +

+
+
+
+
+
+ +
+
+
+ + + +
+
+
+ GitHub for teams +
+

+ A better way to work together +

+

+ GitHub brings teams together to work through problems, move ideas forward, and learn from each other along the way. +

+ +
+ +
+
+
+
+ +
+
+

Write better code

+

+ Collaboration makes perfect. The conversations and code reviews that happen in Pull Requests help your team share the weight of your work and improve the software you build. +

+

+ Learn about code review on GitHub +

+
+
+ +
+
+ +
+
+

Manage your chaos

+

+ Take a deep breath. On GitHub, project management happens in Issues and Projects, right alongside your code. All you have to do is mention a teammate to get them involved. +

+

+ Learn about project management on GitHub +

+
+
+
+
+ +
+ +
+
+ security-admin + +
+ Security and administration +
+

+ Boxes? Check. +

+

+ We worried about your administrative and security needs so you don’t have to. From flexible hosting to authentication options, GitHub can help you meet your team’s requirements. +

+ +

+ + Learn about GitHub for Business + +

+ +
+
+ +
+
+

Code security

+

+ Prevent problems before they happen. Protected branches, signed commits, and required status checks protect your work and help you maintain a high standard for your code. +

+ +

Access controlled

+

+ Encourage teams to work together while limiting access to those who need it with granular permissions and authentication through SAML/SSO and LDAP. +

+ +

Hosted where you need it

+

+ Securely and reliably host your work on GitHub.com. Or, deploy GitHub Enterprise on your own servers or in a private cloud using Amazon Web Services, Azure or Google Cloud Platform. +

+
+
+
+
+ +
+
+
+ integrations + +
+ Integrations +
+

+ Build on GitHub +

+

+ Customize your process with GitHub apps and an intuitive API. Integrate the tools you already use or discover new favorites to create a happier, more efficient way of working. +

+

+ Learn about integrations +

+
+ +
+
+
+
+
+
+
+
+
+ +
+

+ Sometimes, there’s more than one tool for the job. Why not try something new? +

+

+ Browse GitHub Marketplace +

+
+
+
+ + + +
+
+

+ Get started for free — join the millions of developers already using GitHub to share their code, work together, and build amazing things. +

+
+
+
+
+ + + + +
+ + + + + + +
+ + + You can't perform that action at this time. +
+ + + + + + + + + + +
+ + You signed in with another tab or window. Reload to refresh your session. + You signed out in another tab or window. Reload to refresh your session. +
+ + + + + + + \ No newline at end of file diff --git a/monkey/0008/main.py b/monkey/0008/main.py new file mode 100644 index 00000000..08a3aef5 --- /dev/null +++ b/monkey/0008/main.py @@ -0,0 +1,27 @@ +# -*- coding:utf-8 -*- + +''' + +第 0008 题:一个HTML文件,找出里面的正文。 + +@Author monkey +@Date 2017-8-31 +''' +import json + +from bs4 import BeautifulSoup + + +def findContent(): + path = "The world's leading software development platform · GitHub.html" + + with open(path, encoding='UTF-8') as file: + soup = BeautifulSoup(file) + + # print(soup.prettify()) + print(soup.body) + + + +if __name__ == '__main__': + findContent() \ No newline at end of file diff --git "a/monkey/0009/The world's leading software development platform \302\267 GitHub.html" "b/monkey/0009/The world's leading software development platform \302\267 GitHub.html" new file mode 100644 index 00000000..4e6348b9 --- /dev/null +++ "b/monkey/0009/The world's leading software development platform \302\267 GitHub.html" @@ -0,0 +1,757 @@ + + + + + + + + + + + + + + + + + + + + + + + + The world's leading software development platform · GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content +
+ + + + + + + + + + +
+ +
+ +
+
+ + + +
+ + +
+
+
+
+

Built for developers

+

+ GitHub is a development platform inspired by the way you work. From open source to business, you can host and review code, manage projects, and build software alongside millions of other developers. +

+
+
+
+
+
+ +
+
+
+ + + +
+
+
+ GitHub for teams +
+

+ A better way to work together +

+

+ GitHub brings teams together to work through problems, move ideas forward, and learn from each other along the way. +

+ +
+ +
+
+
+
+ +
+
+

Write better code

+

+ Collaboration makes perfect. The conversations and code reviews that happen in Pull Requests help your team share the weight of your work and improve the software you build. +

+

+ Learn about code review on GitHub +

+
+
+ +
+
+ +
+
+

Manage your chaos

+

+ Take a deep breath. On GitHub, project management happens in Issues and Projects, right alongside your code. All you have to do is mention a teammate to get them involved. +

+

+ Learn about project management on GitHub +

+
+
+
+
+ +
+ +
+
+ security-admin + +
+ Security and administration +
+

+ Boxes? Check. +

+

+ We worried about your administrative and security needs so you don’t have to. From flexible hosting to authentication options, GitHub can help you meet your team’s requirements. +

+ +

+ + Learn about GitHub for Business + +

+ +
+
+ +
+
+

Code security

+

+ Prevent problems before they happen. Protected branches, signed commits, and required status checks protect your work and help you maintain a high standard for your code. +

+ +

Access controlled

+

+ Encourage teams to work together while limiting access to those who need it with granular permissions and authentication through SAML/SSO and LDAP. +

+ +

Hosted where you need it

+

+ Securely and reliably host your work on GitHub.com. Or, deploy GitHub Enterprise on your own servers or in a private cloud using Amazon Web Services, Azure or Google Cloud Platform. +

+
+
+
+
+ +
+
+
+ integrations + +
+ Integrations +
+

+ Build on GitHub +

+

+ Customize your process with GitHub apps and an intuitive API. Integrate the tools you already use or discover new favorites to create a happier, more efficient way of working. +

+

+ Learn about integrations +

+
+ +
+
+
+
+
+
+
+
+
+ +
+

+ Sometimes, there’s more than one tool for the job. Why not try something new? +

+

+ Browse GitHub Marketplace +

+
+
+
+ + + +
+
+

+ Get started for free — join the millions of developers already using GitHub to share their code, work together, and build amazing things. +

+
+
+
+
+ + + + +
+ + + + + + +
+ + + You can't perform that action at this time. +
+ + + + + + + + + + +
+ + You signed in with another tab or window. Reload to refresh your session. + You signed out in another tab or window. Reload to refresh your session. +
+ + + + + + + \ No newline at end of file diff --git a/monkey/0009/main.py b/monkey/0009/main.py new file mode 100644 index 00000000..8028f3fc --- /dev/null +++ b/monkey/0009/main.py @@ -0,0 +1,29 @@ +# -*- coding:utf-8 -*- + +''' + +第 0009 题:一个HTML文件,找出里面的链接。 + +@Author monkey +@Date 2017-8-31 +''' +import json + +from bs4 import BeautifulSoup + + +def findTagA(): + path = "The world's leading software development platform · GitHub.html" + + with open(path, encoding='UTF-8') as file: + soup = BeautifulSoup(file) + + # print(soup.prettify()) + links = [] + for i in soup.find_all('a'): + links.append(i['href']) + + print(links) + +if __name__ == '__main__': + findTagA() \ No newline at end of file diff --git a/monkey/0014/main.py b/monkey/0014/main.py new file mode 100644 index 00000000..2f3bc10e --- /dev/null +++ b/monkey/0014/main.py @@ -0,0 +1,56 @@ +# -*- coding:utf-8 -*- + +''' + +第 0014 题: 纯文本文件 student.txt为学生信息, 里面的内容(包括花括号)如下所示: +{ + "1":["张三",150,120,100], + "2":["李四",90,99,95], + "3":["王五",60,66,68] +} +请将上述内容写到 student.xls 文件中。 + +@Author monkey +@Date 2017-8-31 +''' +import json +import xlwt + +def getStudent(): + + with open('student.txt', 'r', encoding = 'UTF-8') as file: + text = '' + for line in file: + text = text + line + + stu_json = json.loads(text, encoding = 'UTF-8') + + print(stu_json) + + writeInXLS(stu_json) + + +def writeInXLS(dict): + fileName = 'student.xls' + # 创建 xls 文件 + file = xlwt.Workbook(encoding = 'utf-8') + # 创建 表 + sheet = file.add_sheet('student', cell_overwrite_ok=True) + + row = 0 + col = 0 + + for k, v in sorted(dict.items(), key=lambda d:d[0]): + sheet.write(row, col, k) + for i in v: + col += 1 + sheet.write(row, col, i) + + row += 1 + col = 0 + + file.save(fileName) + print('写入成功') + +if __name__ == '__main__': + getStudent() \ No newline at end of file diff --git a/monkey/0014/student.txt b/monkey/0014/student.txt new file mode 100644 index 00000000..f06a601f --- /dev/null +++ b/monkey/0014/student.txt @@ -0,0 +1,5 @@ +{ + "1":["张三",150,120,100], + "2":["李四",90,99,95], + "3":["王五",60,66,68] +} \ No newline at end of file diff --git a/monkey/0014/student.xls b/monkey/0014/student.xls new file mode 100644 index 0000000000000000000000000000000000000000..19e2d043900ac52d86d5ae5d0874d6750635b1e2 GIT binary patch literal 5632 zcmeHLO-NKx6#njW#+ecS-lS0mGFVxf8*|e}$AWU@U@a;n&@m-SnPQw4wJ6J6MG@7e zXd}1@!fMkG71XXpVB{hwg3*?(ih>r}>pSQ9Vj2c%2&A8P9`D?9&pG$pd%ttAtPFG7+_$@d&A z+zC7*2j+Pnz%elQ$=C|g4jn_%$Qatm4Q^0ViM2YasPco#S1G@(o{yDxs^)_7c0`di zy_kt7nzu0)7-_%NpteeKgZtX%jcQs^i|6!lPG6G6PHPa`(}$BIf2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0015/main.py new file mode 100644 index 00000000..e4ef735d --- /dev/null +++ b/monkey/0015/main.py @@ -0,0 +1,54 @@ +# -*- coding:utf-8 -*- + +''' +第 0015 题: 纯文本文件 city.txt为城市信息, 里面的内容(包括花括号)如下所示: + +{ + "1" : "上海", + "2" : "北京", + "3" : "成都" +} +请将上述内容写到 city.xls 文件中,如下图所示: + +@Author monkey +@Date 2017-8-31 +''' +import json +import xlwt + +def getCity(): + + with open('city.txt', 'r', encoding='UTF-8') as file: + text = '' + for line in file: + text = text + line + + city_json = json.loads(text, encoding = 'UTF-8') + print(city_json) + + writeInXLS(city_json) + + +def writeInXLS(dict): + fileName = 'city.xls' + + # 创建 文件 + file = xlwt.Workbook() + # 创建 表 + sheet = file.add_sheet('city', cell_overwrite_ok=True) + + row = 0 + col = 0 + + for k, v in sorted(dict.items(), key=lambda d:d[0]): + sheet.write(row, col, k) + col += 1 + sheet.write(row, col, v) + + row += 1 + col = 0 + + file.save(fileName) + +if __name__ == '__main__': + getCity() diff --git a/monkey/0016/main.py b/monkey/0016/main.py new file mode 100644 index 00000000..170ef6bb --- /dev/null +++ b/monkey/0016/main.py @@ -0,0 +1,55 @@ +# -*- coding:utf-8 -*- + +''' +纯文本文件 numbers.txt, 里面的内容(包括方括号)如下所示: + +[ + [1, 82, 65535], + [20, 90, 13], + [26, 809, 1024] +] +请将上述内容写到 numbers.xls 文件中,如下图所示: + +@Author monkey +@Date 2017-8-31 +''' +import json +import xlwt + +def getNumber(): + + with open('numbers.txt', 'r', encoding='UTF-8') as file: + text = '' + for line in file: + text = text + line + + number_json = json.loads(text, encoding = 'UTF-8') + print(number_json) + + writeInXLS(number_json) + + +def writeInXLS(list): + fileName = 'numbers.xls' + + # 创建 文件 + file = xlwt.Workbook() + # 创建 表 + sheet = file.add_sheet('numbers', cell_overwrite_ok=True) + + row = 0 + col = 0 + + + for l in list: + for i in l: + sheet.write(row, col, i) + col += 1 + + row += 1 + col = 0 + + file.save(fileName) + +if __name__ == '__main__': + getNumber() diff --git a/monkey/0016/numbers.txt b/monkey/0016/numbers.txt new file mode 100644 index 00000000..f5062e0a --- /dev/null +++ b/monkey/0016/numbers.txt @@ -0,0 +1,5 @@ +[ + [1, 82, 65535], + [20, 90, 13], + [26, 809, 1024] +] \ No newline at end of file diff --git a/monkey/0016/numbers.xls b/monkey/0016/numbers.xls new file mode 100644 index 0000000000000000000000000000000000000000..3c9c2f3d9c1539874e2cdbf14204a641aaae2d54 GIT binary patch literal 5632 zcmeHLO=uHA6#h0pO(JQUjj3pb5&~9Rdl5mrv|9x&2ukfm5kV81gKdo(^`IB4HAg}4 zqS%^dwa9P+h}ryytxoC&1iiQp-r&wGSCf`Y=Fl;RZD^tkGU2lpj&PQu%H5e5`y(HJ6nSAc3-V z0CUcszO8HvY-ztQt+p7sh5K6Pt!g%*6VK`6p1&fKoz@_>6^>>m|4u`9Ac|QqZ^OBK zu8^55Bgq8L;UB4#u(5aOc*Rkvc@05GHK>hj; z`?!yh{2Y^#)qy8it)i{FnvGo?xXrhfpKXZ0;LzwVIvb7n0g-sab^rhX literal 0 HcmV?d00001