
用Python來(lái)看3天破10億的《我不是藥神》到底神在哪
《我不是藥神》是由文牧野執(zhí)導(dǎo),徐崢、王傳君、周一圍、譚卓、章宇、楊新鳴等主演的喜劇電影,于 2018 年 7 月 6 日在中國(guó)上映。
影片在未上映前,大規(guī)模的點(diǎn)映積攢了相當(dāng)高的人氣和口碑, 截止 7 月 9 日凌晨:豆瓣評(píng)分:9.0 分,貓眼:9.7 分,淘票票:9.5 分,時(shí)光網(wǎng):8.8 分 。
為什么我說(shuō)這三個(gè)網(wǎng)站呢,因?yàn)槲覀兘裉旖?5000+ 條短評(píng)數(shù)據(jù)就來(lái)自于此,用專(zhuān)業(yè)的數(shù)據(jù)更有說(shuō)服力。
綜合幾家的數(shù)據(jù):五星推薦如此之高,生活環(huán)境是真實(shí)的,情緒是真實(shí)的,困境也是真實(shí)的,甚至女主角是一個(gè)真實(shí)的上了年紀(jì)的美女,有真實(shí)的皺紋!真實(shí)才能帶來(lái)沉浸體驗(yàn)。表面說(shuō)的是藥,深層說(shuō)的是命。
藥能治病,命卻不由自主,直面中國(guó)底層生命的苦難和尊嚴(yán),也沒(méi)有逃避對(duì)社會(huì)制度和商業(yè)法則的拷問(wèn),這是影片鍥入中國(guó)現(xiàn)實(shí)的關(guān)鍵,也是引發(fā)大眾共鳴的核心。
盛世危言,卻讓人能看到希望,這部影片極有可能成為 2018 年最具有爆炸性的話題。這也許就是未播先火,豆瓣 16 年后首部 9.0 高分電影的原因。
今天我們用 5000+ 條數(shù)據(jù)來(lái)分析一下,哪些地區(qū),什么樣的人,喜歡這部電影。
程勇只是個(gè)賣(mài)印度神油的小販,日子過(guò)的還湊合。老爹血管瘤急著做手術(shù),住院沒(méi)錢(qián),妻子要帶兒子移民去國(guó)外發(fā)展,靠賣(mài)印度神油掙來(lái)的錢(qián)連水電費(fèi)都交不起,處處都需要錢(qián)。
神秘男子呂受益找到程勇,讓他從印度幫忙代購(gòu)一款藥物。呂受益患有血液癌癥,需要長(zhǎng)期服用抗癌藥物進(jìn)行治療。
正版藥「瑞士格列寧」非常昂貴,普通人家根本供應(yīng)不起,但在印度有一款仿制藥「印度格列寧」價(jià)格卻只有 1/20,但在中國(guó)是屬于禁藥,走私被抓,是需要負(fù)法律責(zé)任的。
在巨大利益的驅(qū)使下,思慧,神父,黃毛先后出場(chǎng),賣(mài)藥五人組團(tuán)建成功,他成為一名“藥販子”。
對(duì)于病友來(lái)說(shuō),他們擁有了活下去的機(jī)會(huì),紛紛給程勇送錦旗,自此稱其為“藥神”。
代購(gòu)的藥出問(wèn)題,假藥販子張長(zhǎng)林的出現(xiàn)威脅程勇,怕被抓,賣(mài)藥組正式散伙。
程勇開(kāi)了工廠,呂受益死,張長(zhǎng)林跑路,讓程勇完成第一次蛻變,許多病人無(wú)藥可吃,程勇再次去印度并重新團(tuán)建賣(mài)藥。
警方嚴(yán)打假藥販子,張長(zhǎng)林被抓。警方發(fā)現(xiàn)程勇窩點(diǎn),黃毛為了掩護(hù)程勇而死,讓他完成第二次蛻變。
以賠本價(jià)繼續(xù)代購(gòu)印度藥,送兒子移民,晚上賣(mài)藥被警察抓。三年后出獄,外面已是改天換地。
《我不是藥神》的現(xiàn)實(shí)意義大于電影本身,許多人評(píng)論這部電影都有些揚(yáng)眉吐氣的感覺(jué),大家都在做一個(gè)中國(guó)電影終于敢說(shuō)真話的夢(mèng)。
截止 7 月 9 日凌晨,累積票房超過(guò) 13 個(gè)億,占當(dāng)天票房近 84%。
是哪些地區(qū)貢獻(xiàn)的票房更多一些,通過(guò)數(shù)據(jù)分析發(fā)現(xiàn):
如這張圖片動(dòng)態(tài)展示的情況,你會(huì)發(fā)現(xiàn)貢獻(xiàn)最多的還是:北京、上海、廣州,二線城市同樣成為票房的貢獻(xiàn)者。
從畫(huà)像來(lái)看,更趨于中年,油膩的中年,人人都怕老病死,人人都怕上下為難,人人都有為謀生計(jì)不得不做的事情,人人亦都向往真與善……是這些時(shí)刻集中起來(lái)讓煽情的《藥神》不那么脫離現(xiàn)實(shí)。
從數(shù)據(jù)上來(lái)看,好看,現(xiàn)實(shí),好片,感人,淚點(diǎn),作品很棒。
“領(lǐng)導(dǎo),我求求你,別再查「假藥」了行么。這藥假不假,我們這些吃的人還不知道么?”
”我吃了三年正版藥,房子吃沒(méi)了,家也吃垮了。現(xiàn)在好不容易有了便宜藥,可你們非說(shuō)這是「假藥」。不吃藥,我們就只能等死?!?
《我不是藥神》戳中的是每個(gè)人的痛點(diǎn),誰(shuí)能保證這一輩子自己和家人不生病呢?
一旦遇上大病,動(dòng)輒上萬(wàn)的高昂醫(yī)藥費(fèi)讓普通人家根本無(wú)力承擔(dān)。一人生病,全家拖垮,真不是危言聳聽(tīng)。
下面我們回歸技術(shù),分享一下我們?nèi)绾潍@取的數(shù)據(jù):
首先是豆瓣,豆瓣自從去年 10 月份已經(jīng)全面禁止爬取數(shù)據(jù),僅僅放出 500 條數(shù)據(jù),豆瓣封 IP,白天一分鐘可以訪問(wèn) 40 次,晚上一分鐘可以訪問(wèn) 60 次,超過(guò)限制次數(shù)就會(huì)封 IP。
import urllib
import requests
from urllibimport request
import time
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win32; x32; rv:54.0) Gecko/20100101 Firefox/54.0',
'Connection': 'keep-alive'}
cookies = 'v=3; iuuid=1A6E888B4A4B29B16FBA1299108DBE9CDCB327A9713C232B36E4DB4FF222CF03; webp=true; ci=1%2C%E5%8C%97%E4%BA%AC; __guid=26581345.3954606544145667000.1530879049181.8303; _lxsdk_cuid=1646f808301c8-0a4e19f5421593-5d4e211f-100200-1646f808302c8; _lxsdk=1A6E888B4A4B29B16FBA1299108DBE9CDCB327A9713C232B36E4DB4FF222CF03; monitor_count=1; _lxsdk_s=16472ee89ec-de2-f91-ed0%7C%7C5; __mta=189118996.1530879050545.1530936763555.1530937843742.18'
def html_prase(url):
r = requests.get(url).content
return r
cookie = {}
for line in cookies.split(';'):
name, value = cookies.strip().split('=', 1)
cookie[name] = value
def html_prase(url):
r = requests.get(url).content
return r
for iin range(1, 100):
print('正在打印第%s頁(yè)' % i)
try:
url= 'http://m.maoyan.com/mmdb/comments/movie/1200486.json?_v_=yes&offset=%s&' % (
i* 15)
print(url)
proxy = html_prase('http://172.17.0.29:5010/get/')..decode('utf-8') # 代理是自建代理池,有需要使用代理的可以聯(lián)系我,知乎ID:布道
html = requests.get(url=url, cookies=cookie, headers=header,
proxies={"http": "http://{}".format(proxy)}).content
data = json.loads(html.decode('utf-8'))['cmts']
for item in data:
comment = item['content']
date = item['time'].split(' ')[0]
rate = item['score']
city = item['cityName']
img= item['avatarurl']
print(date, rate, comment, city, )
with open('maoyan_08.txt', 'a', encoding='utf-8') as f:
f.write(date + ',' + str(rate) + ',' + comment + ',' + comment + ',' + city + '\n')
if img:
f = open('C:\\Users\My\Desktop\yaoshen\img\\' + img.split('/')[-1], 'wb')
f.write((urllib.request.urlopen(img)).read())
except:
continue
time.sleep(5 + float(random.randint(1, 100)) / 20)
另外一種方式:(Anyproxy+JS+Python+Monkeyrunner),可以爬取 Web 靜態(tài)網(wǎng)站、App 應(yīng)用、JS 渲染數(shù)據(jù)的動(dòng)態(tài)網(wǎng)站的數(shù)據(jù)都可以進(jìn)行爬取。
安裝使用,請(qǐng)查閱官方 Github:https://github.com/alibaba/anyproxy
JS 代碼:
var logMap = {}
var fs = require('fs');
var iconv = require('iconv-lite');
var logger = fs.createWriteStream('./urlLog.log', {
flags: 'a' // 'a' means appending (old data will be preserved)
})
function logPageFile(url) {
if (!logMap[url]) {
logMap[url] = true;
logger.write(url + '\r\n');
}
}
function postData(post_data, path, cb) {
// // Build the post string from an object
// var post_data = JSON.stringify({
// 'data': data
// });
// An object of options to indicate where to post to
var post_options = {
host: '127.0.0.1',
port: '9999',
path: '/' + path,
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(post_data)
}
};
var http = require('http');
// Set up the request
var post_req = http.request(post_options, function (res) {
res.setEncoding('utf8');
res.on('data', cb);
});
logger.write('request post data 1\r\n')
// post the data
post_req.write(post_data);
logger.write('request post data 2\r\n')
post_req.end();
}
module.exports = {
summary: 'a rule to modify response',
* beforeSendResponse(requestDetail, responseDetail) {
if (/movie\/1200486/i.test(requestDetail.url)) {
logger.write('matched: ' + requestDetail.url + '\r\n');
if (responseDetail.response.toString() !== "") {
logger.write(responseDetail.response.body.toString());
var post_data = JSON.stringify({
'url': requestDetail.url,
'body': responseDetail.response.body.toString()
});
logger.write("post comment to server -- ext");
postData(post_data, 'douban_comment', function (chunk) {
});
}
}
},
};
使用 AnyProxy 加載 JS 代碼:anyproxy -i --rule wxrule.js
Service 代碼部分:
#!/usr/bin/env python3
import asyncio
import re
import textwrap
import threading
import time
import os
import pymysql
from mysqlmgrimport MysqlMgr
from mongomgrimport MongoManager
from subprocess import call
import requests
from lxmlimport etree
from lxmlimport html
from aiohttp.webimport Application, Response, StreamResponse, run_app
import json
STATE_RUNNING = 1
STATE_IN_TRANSACTION = 2
running_state= 0
run_swipe= True
last_history_time= time.clock()
# A thread to save data to database in background
def insert_to_database(biz, msglist):
try:
for msg in msglist:
print(biz)
print(msg['comm_msg_info']['id'])
mongo_mgr.enqueue_data(msg['comm_msg_info']['id'], biz, msg )
except Exception as e:
print(e)
def save_data(biz, msglist_str):
save_thread= threading.Thread(target=insert_to_database, args=(biz, msglist_str,))
save_thread.setDaemon(True)
save_thread.start()
def swipe_for_next_page():
while run_swipe:
time.sleep(5)
if time.clock() - last_history_time>120:
if running_state== STATE_RUNNING:
reenter()
continue
call(["adb", "shell", "input", "swipe", "400", "1000", "400", "200"])
def reenter():
global running_state
running_state= STATE_IN_TRANSACTION
# 模擬側(cè)滑實(shí)現(xiàn)返回上一頁(yè)
call(["adb", "shell", "input", "swipe", "0", "400", "400", "400"])
time.sleep(2)
# 點(diǎn)擊"進(jìn)入歷史消息",每個(gè)手機(jī)的位置不一樣,需要單獨(dú)設(shè)置 X 和 Y
call(["adb", "shell", "input", "tap", "200", "1200"])
time.sleep(2)
header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0','Connection':'keep-alive'}
def html_prase(url):
r = requests.get(url,header).content
return html.fromstring(r)
async def report_url(request):
resp = StreamResponse()
data = await request.json()
url= data['url']
# print("url reported: " + url)
biz = re.findall('__biz=(.*?)\&', url)
if len(biz) == 0:
await resp.prepare(request)
return resp
biz = biz[0]
print('----------------\r\n'+ biz + '\r\n----------------\r\n')
mysql_mgr.enqueue_biz(biz, '')
bizs.add(biz)
biz = biz.encode('utf8')
resp.content_type= 'text/plain'
await resp.prepare(request)
resp.write(biz)
await resp.write_eof()
return resp
async def intro(request):
txt = textwrap.dedent("""\
Type {url}/hello/John {url}/simple or {url}/change_body
in browser url bar
""").format(url='127.0.0.1:8080')
binary = txt.encode('utf8')
resp = StreamResponse()
resp.content_length= len(binary)
resp.content_type= 'text/plain'
await resp.prepare(request)
resp.write(binary)
return resp
async def simple(request):
return Response(text="Simple answer")
async def change_body(request):
resp = Response()
resp.body= b"Body changed"
resp.content_type= 'text/plain'
return resp
# coding=utf-8
async def app_douban_comment(request):
resp = StreamResponse()
data = await request.json()
global running_state
global last_history_time
msg_data= json.loads(data['body'])['data']['cts']
for item in msg_data:
comment = item['ce'].strip().replace('\n','')
rate = item['cr']
print(comment, rate)
with open('date_rate_comment_sg.txt', 'a', encoding='utf-8') as f:
f.write('2018-07-06' + ',' + str(rate) + ',' + comment + '\n')
last_history_time= time.clock()
resp.content_type= 'text/plain'
await resp.prepare(request)
await resp.write_eof()
return resp
last_history_time= time.clock()
resp.content_type= 'text/plain'
await resp.prepare(request)
await resp.write_eof()
return resp
async def init(loop):
app = Application()
app.router.add_get('/', intro)
app.router.add_post('/url', report_url)
app.router.add_post('/douban_comment', app_douban_comment)
return app
def start_swipe_thread():
try:
t = threading.Thread(
target=swipe_for_next_page, name='swipe')
# set daemon so main thread can exit when receives ctrl-c
t.setDaemon(True)
t.start()
except Exception:
print("Error: unable to start thread")
loop = asyncio.get_event_loop()
app = loop.run_until_complete(init(loop))
run_app(app, host='127.0.0.1', port=9999)
這是示例代碼,實(shí)際使用過(guò)程,需要進(jìn)行微調(diào)。獲取貓眼數(shù)據(jù),最難是難在找貓眼 App 的數(shù)據(jù)接口。
我費(fèi)了很大力氣才找到:http://m.maoyan.com/mmdb/comments/movie/1200486.json?_v_=yes&offset=15'
接口怎么使用,直接看代碼,獲取淘票票的數(shù)據(jù)需要你自己去嘗試找一下。
import json
import random
import urllib
import requests
from urllibimport request
import time
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win32; x32; rv:54.0) Gecko/20100101 Firefox/54.0',
'Connection': 'keep-alive'}
cookies ='v=3; iuuid=1A6E888B4A4B29B16FBA1299108DBE9CDCB327A9713C232B36E4DB4FF222CF03; webp=true; ci=1%2C%E5%8C%97%E4%BA%AC; __guid=26581345.3954606544145667000.1530879049181.8303; _lxsdk_cuid=1646f808301c8-0a4e19f5421593-5d4e211f-100200-1646f808302c8; _lxsdk=1A6E888B4A4B29B16FBA1299108DBE9CDCB327A9713C232B36E4DB4FF222CF03; monitor_count=1; _lxsdk_s=16472ee89ec-de2-f91-ed0%7C%7C5; __mta=189118996.1530879050545.1530936763555.1530937843742.18'
cookie = {}
for line in cookies.split(';'):
name, value = cookies.strip().split('=', 1)
cookie[name] = value
def html_prase(url):
r = requests.get(url).content
return r
for iin range(1, 100):
print('正在打印第%s頁(yè)' % i)
try:
url= 'http://m.maoyan.com/mmdb/comments/movie/1200486.json?_v_=yes&offset=%s&' %(i*15) +'startTime=2018-07-01%2012%3A30%3A42'
print(url)
html = requests.get(url=url, cookies=cookie, headers=header).content
data = json.loads(html.decode('utf-8'))['cmts']
for item in data:
comment = item['content']
date = item['time'].split(' ')[0]
rate = item['score']
city = item['cityName']
img= item['avatarurl']
print(date, rate, comment, city, )
with open('maoyan_08.txt', 'a', encoding='utf-8') as f:
f.write(date + ',' + str(rate) + ',' + comment +',' + comment + ','+ city +'\n')
if img:
f = open('C:\\Users\My\Desktop\yaoshen\img\\' + img.split('/')[-1], 'wb')
f.write((urllib.request.urlopen(img)).read())
except:
break
time.sleep(5 + float(random.randint(1, 100)) / 20)
動(dòng)態(tài)地圖展示代碼:
from pyechartsimport Style
from pyechartsimport Geo
city =[]
with open('maoyan.txt', mode='r', encoding='utf-8') as f:
rows = f.readlines()
for row in rows:
if len(row.split(',')) == 5:
city.append(row.split(',')[4].replace('\n',''))
def all_list(arr):
result = {}
for iin set(arr):
result[i] = arr.count(i)
return result
data = []
for item in all_list(city):
data.append((item,all_list(city)[item]))
style = Style(
title_color="#fff",
title_pos="center",
width=1200,
height=600,
background_color='#404a59'
)
geo = Geo( "《我不是藥神》評(píng)論人群地理位置","數(shù)據(jù)來(lái)源:知乎ID:布道", **style.init_style)
attr, value = geo.cast(data)
geo.add("", attr, value, visual_range=[0, 100],
visual_text_color="#fff", is_legend_show=False,
symbol_size=20, is_visualmap=True,
tooltip_formatter='',
label_emphasis_textsize=15,
label_emphasis_pos='right')
geo.render()
每天爬取數(shù)據(jù)量代碼:
from pyechartsimport EffectScatter
from pyechartsimport Style
style= Style(
title_color="#191970",
title_pos="left",
width=900,
height=450,
background_color='#F8F8FF'
)
es = EffectScatter("《我不是藥神》短評(píng)數(shù)據(jù)情況","數(shù)據(jù)來(lái)源:知乎ID:布道", **style.init_style)
es.add("", [1], [270], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [2], [606], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [3], [542], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [4], [550], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [5], [656], ssymbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [6], [850], ssymbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [7], [993], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.add("", [8], [903], symbol_size=20, effect_scale=4,
effect_period=5, symbol="pin")
es.render()
五星推薦河流圖代碼:
from pyechartsimport Style
from pyechartsimport ThemeRiver
data = [
['2018/07/08', 802, '五星'], ['2018/07/08', 28, '四星'], ['2018/07/08', 9, '三星'], ['2018/07/08',8, '二星'],
['2018/07/08', 4, '一星'],
['2018/07/07',802, '五星'], ['2018/07/07',166, '四星'], ['2018/07/07',17, '三星'],['2018/07/07',0, '二星'],['2018/07/07',8, '一星'],
['2018/07/06', 667, '五星'], ['2018/07/06', 156, '四星'], ['2018/07/06', 13, '三星'], ['2018/07/06', 10, '二星'],['2018/07/06', 4, '一星'],
['2018/07/05', 567, '五星'], ['2018/07/05', 76, '四星'], ['2018/07/05', 13, '三星'], ['2018/07/05', 0, '二星'],['2018/07/05', 0, '一星'],
['2018/07/04', 467, '五星'], ['2018/07/04', 67, '四星'], ['2018/07/04', 16, '三星'], ['2018/07/04', 0, '二星'],['2018/07/04', 0, '一星'],
['2018/07/03', 478, '五星'], ['2018/07/03', 56, '四星'], ['2018/07/03', 8, '三星'], ['2018/07/03', 0, '二星'],['2018/07/03', 0, '一星'],
['2018/07/02', 531, '五星'], ['2018/07/02', 67, '四星'], ['2018/07/02', 8, '三星'], ['2018/07/02', 0, '二星'],['2018/07/02', 0, '一星'],
['2018/07/01', 213, '五星'], ['2018/07/01', 45, '四星'], ['2018/07/01', 5, '三星'], ['2018/07/01', 1, '二星'],
['2018/07/01', 1, '一星'],
]
style = Style(
title_color="#191970",
title_pos="left",
width=1200,
height=600,
background_color='#F8F8FF'
)
tr = ThemeRiver("《我不是藥神》星級(jí)推薦","數(shù)據(jù)來(lái)源:知乎ID:布道", **style.init_style)
tr.add(['五星', '四星', '三星', '二星', '一星',], data, is_label_show=True)
tr.render()
詞云圖:
import pickle
from osimport path
import jieba
import matplotlib.pyplotas plt
from wordcloudimport WordCloud, STOPWORDS, ImageColorGenerator
def make_worldcloud(file_path):
text_from_file_with_apath= open(file_path,'r',encoding='UTF-8').read()
wordlist_after_jieba= jieba.cut(text_from_file_with_apath, cut_all=False)
wl_space_split= " ".join(wordlist_after_jieba)
print(wl_space_split)
backgroud_Image= plt.imread('./1.jpg')
print('加載圖片成功!')
'''設(shè)置詞云樣式'''
stopwords= STOPWORDS.copy()
stopwords.add("哈哈")
stopwords.add("電影")
stopwords.add("真的")
stopwords.add("就是")
stopwords.add("真是")
stopwords.add("中國(guó)")
stopwords.add("沒(méi)有")
stopwords.add("可以")
stopwords.add("一部")
stopwords.add("還是")
stopwords.add("最后")
stopwords.add("一個(gè)") #可以加多個(gè)屏蔽詞#可以加多個(gè)屏蔽詞
wc= WordCloud(
width=1024,
height=768,
background_color='white',# 設(shè)置背景顏色
mask=backgroud_Image,# 設(shè)置背景圖片
font_path='E:\simsun.ttf', # 設(shè)置中文字體,若是有中文的話,這句代碼必須添加,不然會(huì)出現(xiàn)方框,不出現(xiàn)漢字
max_words=600, # 設(shè)置最大現(xiàn)實(shí)的字?jǐn)?shù)
stopwords=stopwords,# 設(shè)置停用詞
max_font_size=400,# 設(shè)置字體最大值
random_state=50,# 設(shè)置有多少種隨機(jī)生成狀態(tài),即有多少種配色方案
)
wc.generate_from_text(wl_space_split)#開(kāi)始加載文本
img_colors= ImageColorGenerator(backgroud_Image)
wc.recolor(color_func=img_colors)#字體顏色為背景圖片的顏色
plt.imshow(wc)# 顯示詞云圖
plt.axis('off')# 是否顯示x軸、y軸下標(biāo)
plt.show()#顯示
# 獲得模塊所在的路徑的
d = path.dirname(__file__)
# os.path.join(): 將多個(gè)路徑組合后返回
wc.to_file(path.join(d, "h11.jpg"))
print('生成詞云成功!')
make_worldcloud('cloud.txt')
圖像畫(huà)像代碼:
import os
from math import sqrt
from PIL import Image
#path是存放好友頭像圖的文件夾的路徑
path = 'C:\\Users\My\Desktop\yaoshen\img\\'
pathList= []
for item in os.listdir(path):
imgPath= os.path.join(path,item)
pathList.append(imgPath)
total = len(pathList)#total是好友頭像圖片總數(shù)
line = int(sqrt(total))#line是拼接圖片的行數(shù)(即每一行包含的圖片數(shù)量)
NewImage= Image.new('RGB', (128*line,128*line))
x = y = 0
for item in pathList:
try:
img= Image.open(item)
img= img.resize((128,128),Image.ANTIALIAS)
NewImage.paste(img, (x * 128 , y * 128))
x += 1
except IOError:
print("第%d行,%d列文件讀取失?。OError:%s" % (y,x,item))
x -= 1
if x == line:
x = 0
y += 1
if (x+line*y) == line*line:
break
NewImage.save(path+"final.jpg")
數(shù)據(jù)分析咨詢請(qǐng)掃描二維碼
若不方便掃碼,搜微信號(hào):CDAshujufenxi
LSTM 模型輸入長(zhǎng)度選擇技巧:提升序列建模效能的關(guān)鍵? 在循環(huán)神經(jīng)網(wǎng)絡(luò)(RNN)家族中,長(zhǎng)短期記憶網(wǎng)絡(luò)(LSTM)憑借其解決長(zhǎng)序列 ...
2025-07-11CDA 數(shù)據(jù)分析師報(bào)考條件詳解與準(zhǔn)備指南? ? 在數(shù)據(jù)驅(qū)動(dòng)決策的時(shí)代浪潮下,CDA 數(shù)據(jù)分析師認(rèn)證愈發(fā)受到矚目,成為眾多有志投身數(shù) ...
2025-07-11數(shù)據(jù)透視表中兩列相乘合計(jì)的實(shí)用指南? 在數(shù)據(jù)分析的日常工作中,數(shù)據(jù)透視表憑借其強(qiáng)大的數(shù)據(jù)匯總和分析功能,成為了 Excel 用戶 ...
2025-07-11尊敬的考生: 您好! 我們誠(chéng)摯通知您,CDA Level I和 Level II考試大綱將于 2025年7月25日 實(shí)施重大更新。 此次更新旨在確保認(rèn) ...
2025-07-10BI 大數(shù)據(jù)分析師:連接數(shù)據(jù)與業(yè)務(wù)的價(jià)值轉(zhuǎn)化者? ? 在大數(shù)據(jù)與商業(yè)智能(Business Intelligence,簡(jiǎn)稱 BI)深度融合的時(shí)代,BI ...
2025-07-10SQL 在預(yù)測(cè)分析中的應(yīng)用:從數(shù)據(jù)查詢到趨勢(shì)預(yù)判? ? 在數(shù)據(jù)驅(qū)動(dòng)決策的時(shí)代,預(yù)測(cè)分析作為挖掘數(shù)據(jù)潛在價(jià)值的核心手段,正被廣泛 ...
2025-07-10數(shù)據(jù)查詢結(jié)束后:分析師的收尾工作與價(jià)值深化? ? 在數(shù)據(jù)分析的全流程中,“query end”(查詢結(jié)束)并非工作的終點(diǎn),而是將數(shù) ...
2025-07-10CDA 數(shù)據(jù)分析師考試:從報(bào)考到取證的全攻略? 在數(shù)字經(jīng)濟(jì)蓬勃發(fā)展的今天,數(shù)據(jù)分析師已成為各行業(yè)爭(zhēng)搶的核心人才,而 CDA(Certi ...
2025-07-09【CDA干貨】單樣本趨勢(shì)性檢驗(yàn):捕捉數(shù)據(jù)背后的時(shí)間軌跡? 在數(shù)據(jù)分析的版圖中,單樣本趨勢(shì)性檢驗(yàn)如同一位耐心的偵探,專(zhuān)注于從單 ...
2025-07-09year_month數(shù)據(jù)類(lèi)型:時(shí)間維度的精準(zhǔn)切片? ? 在數(shù)據(jù)的世界里,時(shí)間是最不可或缺的維度之一,而year_month數(shù)據(jù)類(lèi)型就像一把精準(zhǔn) ...
2025-07-09CDA 備考干貨:Python 在數(shù)據(jù)分析中的核心應(yīng)用與實(shí)戰(zhàn)技巧? ? 在 CDA 數(shù)據(jù)分析師認(rèn)證考試中,Python 作為數(shù)據(jù)處理與分析的核心 ...
2025-07-08SPSS 中的 Mann-Kendall 檢驗(yàn):數(shù)據(jù)趨勢(shì)與突變分析的有力工具? ? ? 在數(shù)據(jù)分析的廣袤領(lǐng)域中,準(zhǔn)確捕捉數(shù)據(jù)的趨勢(shì)變化以及識(shí)別 ...
2025-07-08備戰(zhàn) CDA 數(shù)據(jù)分析師考試:需要多久?如何規(guī)劃? CDA(Certified Data Analyst)數(shù)據(jù)分析師認(rèn)證作為國(guó)內(nèi)權(quán)威的數(shù)據(jù)分析能力認(rèn)證 ...
2025-07-08LSTM 輸出不確定的成因、影響與應(yīng)對(duì)策略? 長(zhǎng)短期記憶網(wǎng)絡(luò)(LSTM)作為循環(huán)神經(jīng)網(wǎng)絡(luò)(RNN)的一種變體,憑借獨(dú)特的門(mén)控機(jī)制,在 ...
2025-07-07統(tǒng)計(jì)學(xué)方法在市場(chǎng)調(diào)研數(shù)據(jù)中的深度應(yīng)用? 市場(chǎng)調(diào)研是企業(yè)洞察市場(chǎng)動(dòng)態(tài)、了解消費(fèi)者需求的重要途徑,而統(tǒng)計(jì)學(xué)方法則是市場(chǎng)調(diào)研數(shù) ...
2025-07-07CDA數(shù)據(jù)分析師證書(shū)考試全攻略? 在數(shù)字化浪潮席卷全球的當(dāng)下,數(shù)據(jù)已成為企業(yè)決策、行業(yè)發(fā)展的核心驅(qū)動(dòng)力,數(shù)據(jù)分析師也因此成為 ...
2025-07-07剖析 CDA 數(shù)據(jù)分析師考試題型:解鎖高效備考與答題策略? CDA(Certified Data Analyst)數(shù)據(jù)分析師考試作為衡量數(shù)據(jù)專(zhuān)業(yè)能力的 ...
2025-07-04SQL Server 字符串截取轉(zhuǎn)日期:解鎖數(shù)據(jù)處理的關(guān)鍵技能? 在數(shù)據(jù)處理與分析工作中,數(shù)據(jù)格式的規(guī)范性是保證后續(xù)分析準(zhǔn)確性的基礎(chǔ) ...
2025-07-04CDA 數(shù)據(jù)分析師視角:從數(shù)據(jù)迷霧中探尋商業(yè)真相? 在數(shù)字化浪潮席卷全球的今天,數(shù)據(jù)已成為企業(yè)決策的核心驅(qū)動(dòng)力,CDA(Certifie ...
2025-07-04CDA 數(shù)據(jù)分析師:開(kāi)啟數(shù)據(jù)職業(yè)發(fā)展新征程? ? 在數(shù)據(jù)成為核心生產(chǎn)要素的今天,數(shù)據(jù)分析師的職業(yè)價(jià)值愈發(fā)凸顯。CDA(Certified D ...
2025-07-03