主頁 > 後端開發 > 【Python爬蟲】:使用高性能異步多行程爬蟲獲取豆瓣電影Top250

【Python爬蟲】:使用高性能異步多行程爬蟲獲取豆瓣電影Top250

2021-02-01 06:13:59 後端開發

在本篇博文當中,將會教會大家如何使用高性能爬蟲,快速爬取并決議頁面當中的資訊,一般情況下,如果我們請求網頁的次數太多,每次都要發出一次請求,進行串行執行的話,那么請求將會占用我們大量的時間,這樣得不償失,因此我們可以i使用高性能爬蟲,也就是采用多行程,異步的方式對資料進行爬取和決議,這樣就可以在更快的時間內得到我們想要的結果,本篇博文給出有關爬取豆瓣電影的例子,以此來教會大家如何使用高性能爬蟲,

一.網頁分析

首先我們來分析豆瓣電影的網頁代碼,在本次的案例當中,我們需要爬取豆瓣電影top250當中的標題title和星數star,

 

 發現,豆瓣電影當中的所有有關電影的資訊全部都隱藏在< ol >這個標簽,當中,因此我們在撰寫xpath的時候,可以利用對它做一個回圈,然后又發現,對于電影的title而言,有兩個地方出現,一個地方是在圖片上,另一個地方是在span標簽下的class = title處,但是在span標簽下具有多個標題,為了以免引起混,因此我們使用圖片當中所暗含的標題title文字,使用xpath進行定位即可,

對于star而言,就更加簡單了,我們發現每次一個star的分數出現,就會有又一個<div >的標簽在前面,然后再出現了與span有關的標簽,因此我們撰寫xpath運算式為://ol[@]//div[@]/span[@]/text()

這樣就可以得到一整個頁面的star的數值了,當然這樣我們只能獲取第一頁的我們想要得到的資料,怎么得到第二頁的資料呢?

二.翻頁處理

翻頁處理對于豆瓣電影這個網站還是比較簡單的,我們分別查看第一,二,三頁的url,就會驚奇的發現它的網址如下:

https://movie.douban.com/top250?start=0&filter=
https://movie.douban.com/top250?start=25&filter=
https://movie.douban.com/top250?start=50&filter=

十分明顯,這個網址后面有問號說明想要獲取頁面內容肯定需要發起get請求,都沒有做有關post請求的加密,這樣看來這也太簡單了吧!

同樣的我們發現里面的引數start在不斷的變化,而filter卻保持不變,因此我們只需要得到start引數的規律就知道該怎么撰寫爬蟲了,

對于start而言,每跳轉一頁,就會增加25的數值,因為每一個頁面里面均僅有25部電影,這樣我們就找到了start引數的規律,開始撰寫爬蟲,

三.爬蟲代碼的撰寫

在撰寫的代碼時候,我們匯入了多行程的庫,使用這個庫進行爬蟲,也就只需要在原本代碼的基礎之上多添加兩行代碼即可,如下所示:

pool=Pool(4)
pool.map(get_information,number_ls)

這兩行代碼當中,第一個引數的4表示了我們使用4個行程的行程池進行資料的抓取,數值越大,爬取的效率就越高,這取決于你CPU的數量,數值不能超過CPU核心數的數量,因為一個一個CPU核心同時只能夠運行單個行程,

第二行代碼使用了map函式,第一個引數填寫我們進行爬蟲的函式,第二個引數填寫爬蟲函式所需要的引數,把這兩個東西放到map函式里,就可以開始高性能爬蟲了,

Remark:
在進行行程池爬蟲的時候,我們放入的引數number_ls一定是一個串列,同時我們在get_imformation函式里使用得到的引數時,每次系統會呼叫這個引數串列當中的任意一個數值,而不是對整個串列進行呼叫,

由于整個原因,因此我們撰寫整個的代碼·如下所示:

import requests
from lxml import etree
from multiprocessing.dummy import Pool
cookie='bid=N3Zqe_FFUKc; douban-fav-remind=1; viewed="27093751"; _vwo_uuid_v2=D401F17C96234AE149C4E04B78C3C8066|6fcc3cefe576bff2b89cdf28c4c5f597; __gads=ID=21cdec44606b00df-2250ba4d7ac4009b:T=1604034713:RT=1604034713:S=ALNI_Mb6iYJKYfbUjLxlisTQX5HCODTGKg; gr_user_id=fb6ac40c-94c3-400e-b170-47e126a9b78a; _gid=GA1.2.1520341169.1612004212; _ga=GA1.2.645228582.1602221486; ll="108288"; UM_distinctid=17752f076e4530-0b6eef25ebabba-f7b1332-1fa400-17752f076e57f0; Hm_lvt_19fc7b106453f97b6a84d64302f21a04=1612004228; Hm_lpvt_19fc7b106453f97b6a84d64302f21a04=1612004253; ap_v=0,6.0; _pk_ref.100001.4cf6=%5B%22%22%2C%22%22%2C1612004299%2C%22https%3A%2F%2Fwww.google.com%2F%22%5D; _pk_ses.100001.4cf6=*; __utma=30149280.645228582.1602221486.1611225800.1612004300.9; __utmb=30149280.0.10.1612004300; __utmc=30149280; __utmz=30149280.1612004300.9.9.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __utma=223695111.645228582.1602221486.1612004300.1612004300.1; __utmb=223695111.0.10.1612004300; __utmc=223695111; __utmz=223695111.1612004300.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); _pk_id.100001.4cf6=9a1bb1df4597b334.1612004299.1.1612005471.1612004299.'

headers={
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36',
}

url='https://movie.douban.com/top250'


number_ls=[]
for i in range(0,251,25):
    number_ls.append(i)

print(number_ls)


def get_information(number_ls):
    param={
        'start':number_ls,
        'filter' :''
    }
    page_content=requests.get(url=url,headers=headers,params=param).text

    with open('douban.html','w',encoding='utf-8') as fp:
        fp.write(page_content)

    tree=etree.HTML(page_content)
    vedio_title=tree.xpath('//ol[@]//div[@]//a/img/@alt')
    star=tree.xpath('//ol[@]//div[@]/span[@]/text()')

    vedio_title_ls=[]
    star_ls=[]
    for i in vedio_title:
        vedio_title_ls.append(i)
    for i in star:
        star_ls.append(i)

    j=0
    while j<len(star_ls):
        print("the movie is ",vedio_title_ls[j])
        print("the star is ",star_ls[j])
        print()
        j+=1

pool=Pool(4)
pool.map(get_information,number_ls)

四.輸出的結果

輸出的結果十分完美,一共有250份電影,如下圖所示:

[0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250]
the movie is  搏擊俱樂部
the star is  9.0

the movie is  教父2
the star is  9.2

the movie is  獅子王
the star is  9.0

the movie is  指環王2:雙塔奇兵
the star is  9.1

the movie is  死亡詩社
the star is  9.1

the movie is  鋼琴家
the star is  9.2

the movie is  黑客帝國
the star is  9.0

the movie is  指環王1:魔戒再現
the star is  9.0

the movie is  飲食男女
the star is  9.1

the movie is  竊聽風暴
the star is  9.1

the movie is  美麗心靈
the star is  9.0

the movie is  讓子彈飛
the star is  8.8

the movie is  綠皮書
the star is  8.9

the movie is  兩桿大煙槍
the star is  9.1

the movie is  本杰明·巴頓奇事
the star is  8.9

the movie is  海蒂和爺爺
the star is  9.2

the movie is  飛越瘋人院
the star is  9.1

the movie is  看不見的客人
the star is  8.8

the movie is  西西里的美麗傳說
the star is  8.9

the movie is  拯救大兵瑞恩
the star is  9.0

the movie is  穿條紋睡衣的男孩
the star is  9.1

the movie is  小鞋子
the star is  9.2

the movie is  音樂之聲
the star is  9.0

the movie is  情書
the star is  8.9

the movie is  海豚灣
the star is  9.3

the movie is  美國往事
the star is  9.2

the movie is  致命魔術
the star is  8.9

the movie is  沉默的羔羊
the star is  8.9

the movie is  低俗小說
the star is  8.9

the movie is  禁閉島
the star is  8.8

the movie is  蝴蝶效應
the star is  8.8

the movie is  七宗罪
the star is  8.8

the movie is  心靈捕手
the star is  8.9

the movie is  布達佩斯大飯店
the star is  8.9

the movie is  春光乍泄
the star is  8.9

the movie is  摩登時代
the star is  9.3

the movie is  被嫌棄的松子的一生
the star is  8.9

the movie is  哈利·波特與死亡圣器(下)
the star is  8.9

the movie is  阿凡達
the star is  8.7

the movie is  喜劇之王
the star is  8.8

the movie is  致命ID
the star is  8.8

the movie is  剪刀手愛德華
the star is  8.7

the movie is  勇敢的心
the star is  8.9

the movie is  加勒比海盜
the star is  8.8

the movie is  殺人回憶
the star is  8.9

the movie is  狩獵
the star is  9.1

the movie is  請以你的名字呼喚我
the star is  8.9

the movie is  天使愛美麗
the star is  8.7

the movie is  斷背山
the star is  8.8

the movie is  紅辣椒
the star is  9.0

the movie is  觸不可及
the star is  9.2

the movie is  蝙蝠俠:黑暗騎士
the star is  9.2

the movie is  末代皇帝
the star is  9.3

the movie is  活著
the star is  9.3

the movie is  尋夢環游記
the star is  9.1

the movie is  亂世佳人
the star is  9.3

the movie is  何以為家
the star is  9.1

the movie is  指環王3:王者無敵
the star is  9.2

the movie is  飛屋環游記
the star is  9.0

the movie is  摔跤吧!爸爸
the star is  9.0

the movie is  哈利·波特與魔法石
the star is  9.1

the movie is  素媛
the star is  9.3

the movie is  少年派的奇幻漂流
the star is  9.1

the movie is  十二怒漢
the star is  9.4

the movie is  哈爾的移動城堡
the star is  9.1

the movie is  鬼子來了
the star is  9.3

the movie is  天空之城
the star is  9.1

the movie is  大話西游之月光寶盒
the star is  9.0

the movie is  我不是藥神
the star is  9.0

the movie is  聞香識女人
the star is  9.1

the movie is  羅馬假日
the star is  9.0

the movie is  天堂電影院
the star is  9.2

the movie is  辯護人
the star is  9.2

the movie is  貓鼠游戲
the star is  9.0

the movie is  大鬧天宮
the star is  9.4

the movie is  肖申克的救贖
the star is  9.7

the movie is  霸王別姬
the star is  9.6

the movie is  阿甘正傳
the star is  9.5

the movie is  這個殺手不太冷
the star is  9.4

the movie is  泰坦尼克號
the star is  9.4

the movie is  美麗人生
the star is  9.5

the movie is  千與千尋
the star is  9.4

the movie is  辛德勒的名單
the star is  9.5

the movie is  盜夢空間
the star is  9.3

the movie is  忠犬八公的故事
the star is  9.4

the movie is  星際穿越
the star is  9.3

the movie is  海上鋼琴師
the star is  9.3

the movie is  楚門的世界
the star is  9.3

the movie is  三傻大鬧寶萊塢
the star is  9.2

the movie is  機器人總動員
the star is  9.3

the movie is  放牛班的春天
the star is  9.3

the movie is  大話西游之大圣娶親
the star is  9.2

the movie is  瘋狂動物城
the star is  9.2

the movie is  無間道
the star is  9.2

the movie is  熔爐
the star is  9.3

the movie is  教父
the star is  9.3

the movie is  當幸福來敲門
the star is  9.1

the movie is  龍貓
the star is  9.2

the movie is  怦然心動
the star is  9.1

the movie is  控方證人
the star is  9.6

the movie is  7號房的禮物
the star is  8.9

the movie is  幽靈公主
the star is  8.9

the movie is  小森林 夏秋篇
the star is  9.0

the movie is  陽光燦爛的日子
the star is  8.8

the movie is  第六感
the star is  8.9

the movie is  重慶森林
the star is  8.8

the movie is  入殮師
the star is  8.9

the movie is  唐伯虎點秋香
the star is  8.7

the movie is  小森林 冬春篇
the star is  9.0

the movie is  愛在黎明破曉前
the star is  8.8

the movie is  超脫
the star is  8.9

the movie is  消失的愛人
the star is  8.7

the movie is  一一
the star is  9.0

the movie is  菊次郎的夏天
the star is  8.8

the movie is  蝙蝠俠:黑暗騎士崛起
the star is  8.8

the movie is  側耳傾聽
the star is  8.9

the movie is  倩女幽魂
the star is  8.7

the movie is  功夫
the star is  8.6

the movie is  超能陸戰隊
the star is  8.7

the movie is  無人知曉
the star is  9.1

the movie is  人生果實
the star is  9.5

the movie is  螢火之森
the star is  8.9

the movie is  甜蜜蜜
the star is  8.8

the movie is  借東西的小人阿莉埃蒂
the star is  8.8

the movie is  瑪麗和馬克思
the star is  8.9

the movie is  愛在日落黃昏時
the star is  8.8

the movie is  馴龍高手
the star is  8.7

the movie is  完美的世界
the star is  9.1

the movie is  幸福終點站
the star is  8.8

the movie is  告白
the star is  8.7

the movie is  大魚
the star is  8.8

the movie is  陽光姐妹淘
the star is  8.8

the movie is  射雕英雄傳之東成西就
the star is  8.7

the movie is  哈利·波特與阿茲卡班的囚徒
the star is  8.8

the movie is  恐怖直播
the star is  8.8

the movie is  天書奇譚
the star is  9.2

the movie is  怪獸電力公司
the star is  8.7

the movie is  神偷奶爸
the star is  8.6

the movie is  玩具總動員3
the star is  8.8

the movie is  傲慢與偏見
the star is  8.6

the movie is  時空戀旅人
the star is  8.8

the movie is  哈利·波特與密室
the star is  8.7

the movie is  教父3
the star is  8.9

the movie is  釜山行
the star is  8.6

the movie is  血戰鋼鋸嶺
the star is  8.7

the movie is  哪吒鬧海
the star is  9.1

the movie is  被解救的姜戈
the star is  8.7

the movie is  七武士
the star is  9.3

the movie is  喜宴
the star is  8.9

the movie is  電鋸驚魂
the star is  8.7

the movie is  爆裂鼓手
the star is  8.7

the movie is  貧民窟的百萬富翁
the star is  8.6

the movie is  螢火蟲之墓
the star is  8.7

the movie is  東邪西毒
the star is  8.6

the movie is  海街日記
the star is  8.8

the movie is  黑天鵝
the star is  8.6

the movie is  驚魂記
the star is  9.0

the movie is  無敵破壞王
the star is  8.7

the movie is  你看起來好像很好吃
the star is  8.9

the movie is  冰川時代
the star is  8.6

the movie is  雨人
the star is  8.7

the movie is  小偷家族
the star is  8.7

the movie is  綠里奇跡
the star is  8.9

the movie is  戀戀筆記本
the star is  8.5

the movie is  愛在午夜降臨前
the star is  8.8

the movie is  瘋狂的石頭
the star is  8.5

the movie is  哈利·波特與火焰杯
the star is  8.6

the movie is  寄生蟲
the star is  8.7

the movie is  恐怖游輪
the star is  8.5

the movie is  奇跡男孩
the star is  8.6

the movie is  雨中曲
the star is  9.0

the movie is  魔女宅急便
the star is  8.7

the movie is  二十二
the star is  8.7

the movie is  海邊的曼徹斯特
the star is  8.6

the movie is  房間
the star is  8.8

the movie is  風之谷
the star is  8.9

the movie is  一個叫歐維的男人決定去死
the star is  8.9

the movie is  我是山姆
the star is  8.9

the movie is  頭號玩家
the star is  8.7

the movie is  英雄本色
the star is  8.7

the movie is  上帝之城
the star is  9.0

the movie is  諜影重重3
the star is  8.8

the movie is  瘋狂原始人
the star is  8.7

the movie is  未麻的部屋
the star is  9.0

the movie is  歲月神偷
the star is  8.7

the movie is  盧旺達飯店
the star is  8.9

the movie is  縱橫四海
the star is  8.8

the movie is  三塊廣告牌
the star is  8.7

the movie is  達拉斯買家俱樂部
the star is  8.8

the movie is  花樣年華
the star is  8.7

the movie is  心迷宮
the star is  8.7

the movie is  記憶碎片
the star is  8.6

the movie is  模仿游戲
the star is  8.7

the movie is  黑客帝國3:矩陣革命
the star is  8.8

the movie is  新世界
the star is  8.8

the movie is  頭腦特工隊
the star is  8.7

the movie is  荒蠻故事
the star is  8.8

the movie is  你的名字,
the star is  8.4

the movie is  真愛至上
the star is  8.6

the movie is  忠犬八公物語
the star is  9.2

the movie is  諜影重重2
the star is  8.7

the movie is  阿飛正傳
the star is  8.5

the movie is  地球上的星星
the star is  8.9

the movie is  彗星來的那一夜
the star is  8.5

the movie is  完美陌生人
the star is  8.5

the movie is  戰爭之王
the star is  8.7

the movie is  諜影重重
the star is  8.6

the movie is  香水
the star is  8.5

the movie is  東京教父
the star is  9.0

the movie is  東京物語
the star is  9.2

the movie is  朗讀者
the star is  8.6

the movie is  千鈞一發
the star is  8.8

the movie is  再次出發之紐約遇見你
the star is  8.6

the movie is  驢得水
the star is  8.3

the movie is  猜火車
the star is  8.5

the movie is  黑客帝國2:重裝上陣
the star is  8.6

the movie is  無間道2
the star is  8.6

the movie is  我愛你
the star is  9.1

the movie is  浪潮
the star is  8.7

the movie is  崖上的波妞
the star is  8.5

the movie is  聚焦
the star is  8.8

the movie is  小蘿莉的猴神大叔
the star is  8.4

the movie is  追隨
the star is  8.9

the movie is  黑鷹墜落
the star is  8.7

the movie is  網路謎蹤
the star is  8.6

the movie is  虎口脫險
the star is  8.9

the movie is  人工智能
the star is  8.7

the movie is  九品芝麻官
the star is  8.6

the movie is  2001太空漫游
the star is  8.8

the movie is  可可西里
the star is  8.8

the movie is  羅生門
the star is  8.8

the movie is  色,戒
the star is  8.5

the movie is  終結者2:審判日
the star is  8.7

the movie is  城市之光
the star is  9.3

the movie is  初戀這件小事
the star is  8.4

the movie is  魂斷藍橋
the star is  8.8

the movie is  牯嶺街少年殺人事件
the star is  8.9

the movie is  遺愿清單
the star is  8.7

the movie is  大佛普拉斯
the star is  8.7

the movie is  新龍門客堆疊
the star is  8.6

the movie is  波西米亞狂想曲
the star is  8.7

the movie is  源代碼
the star is  8.5

the movie is  青蛇
the star is  8.6

the movie is  海洋
the star is  9.1

the movie is  燃情歲月
the star is  8.8

the movie is  無恥混蛋
the star is  8.6

the movie is  瘋狂的麥克斯4:狂暴之路
the star is  8.6

the movie is  血鉆
the star is  8.7

the movie is  穿越時空的少女
the star is  8.6

the movie is  步履不停
the star is  8.8

 

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/255062.html

標籤:Python

上一篇:《Effective Java》筆記

下一篇:839相似字串

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more