Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions JiYouMCC/0013/0013.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import urllib2
import urllib
import re
import os
import uuid
Expand Down Expand Up @@ -32,13 +33,9 @@ def get_images(html_url='http://ycool.com/post/ae3u4zu',
if ex is '':
continue
filename += ex
file_request = urllib2.Request(img)
try:
file_response = urllib2.urlopen(file_request)
output = open(os.path.join(folder_name, filename), 'w+')
output.write(file_response.read())
urllib.urlretrieve(img, os.path.join(folder_name, filename))
print 'Image save at %s' % output.name
output.close()
except Exception, ex:
print ex
except Exception, e:
Expand Down
13 changes: 13 additions & 0 deletions JiYouMCC/0014/0014.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 第 0014 题 #

第 0014 题: 纯文本文件 student.txt为学生信息, 里面的内容(包括花括号)如下所示:

{
"1":["张三",150,120,100],
"2":["李四",90,99,95],
"3":["王五",60,66,68]
}

请将上述内容写到 student.xls 文件中,如下图所示:

![student.xls](https://camo.githubusercontent.com/18dea9401449e4ca894d40d55134d9c28083280d/687474703a2f2f692e696d6775722e636f6d2f6e50446c706d652e6a7067)
18 changes: 18 additions & 0 deletions JiYouMCC/0014/0014.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
import xlwt
import json
import sys
reload(sys)

sys.setdefaultencoding('utf8')


file = xlwt.Workbook(encoding='utf-8')
table = file.add_sheet('student', cell_overwrite_ok=True)
txt = open('student.txt').read()
json_txt = json.loads(txt)
for x in range(len(json_txt)):
table.write(x, 0, x + 1)
for y in range(len(json_txt[str(x + 1)])):
table.write(x, y + 1, json_txt[str(x + 1)][y])
file.save('students.xls')
5 changes: 5 additions & 0 deletions JiYouMCC/0014/student.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"1":["张三",150,120,100],
"2":["李四",90,99,95],
"3":["王五",60,66,68]
}
11 changes: 11 additions & 0 deletions JiYouMCC/0015/0015.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
第 0015 题: 纯文本文件 city.txt为城市信息, 里面的内容(包括花括号)如下所示:

{
"1" : "上海",
"2" : "北京",
"3" : "成都"
}

请将上述内容写到 city.xls 文件中,如下图所示:

![city.xls](https://camo.githubusercontent.com/61120377319bfe5520c9d73f51776f923d6bd3b7/687474703a2f2f692e696d6775722e636f6d2f724f4862557a672e706e67)
17 changes: 17 additions & 0 deletions JiYouMCC/0015/0015.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
import xlwt
import json
import sys
reload(sys)

sys.setdefaultencoding('utf8')


file = xlwt.Workbook(encoding='utf-8')
table = file.add_sheet('city', cell_overwrite_ok=True)
txt = open('city.txt').read()
json_txt = json.loads(txt)
for x in range(len(json_txt)):
table.write(x, 0, x + 1)
table.write(x, 1, json_txt[str(x + 1)])
file.save('city.xls')
5 changes: 5 additions & 0 deletions JiYouMCC/0015/city.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"1" : "上海",
"2" : "北京",
"3" : "成都"
}
11 changes: 11 additions & 0 deletions JiYouMCC/0016/0016.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
第 0016 题: 纯文本文件 numbers.txt, 里面的内容(包括方括号)如下所示:

[
[1, 82, 65535],
[20, 90, 13],
[26, 809, 1024]
]

请将上述内容写到 numbers.xls 文件中,如下图所示:

![numbers.xls](https://camo.githubusercontent.com/60da4d596289212b517547ddcc2408bfc9f39087/687474703a2f2f692e696d6775722e636f6d2f69757a305062762e706e67)
17 changes: 17 additions & 0 deletions JiYouMCC/0016/0016.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
import xlwt
import json
import sys
reload(sys)

sys.setdefaultencoding('utf8')


file = xlwt.Workbook(encoding='utf-8')
table = file.add_sheet('numbers', cell_overwrite_ok=True)
txt = open('numbers.txt').read()
json_txt = json.loads(txt)
for x in range(len(json_txt)):
for y in range(len(json_txt[x])):
table.write(x, y, json_txt[x][y])
file.save('numbers.xls')
5 changes: 5 additions & 0 deletions JiYouMCC/0016/numbers.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
[1, 82, 65535],
[20, 90, 13],
[26, 809, 1024]
]