第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何優(yōu)化 json 數(shù)據(jù)對象中 10 個(gè)最常用詞的檢索?

如何優(yōu)化 json 數(shù)據(jù)對象中 10 個(gè)最常用詞的檢索?

忽然笑 2021-09-25 21:53:14
我正在尋找使代碼更高效的方法(運(yùn)行時(shí)和內(nèi)存復(fù)雜性) 我應(yīng)該使用像 Max-Heap 這樣的東西嗎?由于字符串連接或字典排序不就地或其他原因?qū)е碌男阅懿患眩?編輯:我將字典/地圖對象替換為在所有檢索到的名稱列表上應(yīng)用 Counter 方法(有重復(fù))最小請求: 腳本應(yīng)該花費(fèi)少于 30 秒 當(dāng)前運(yùn)行時(shí)間:它需要 54 秒   # Try to implement the program efficiently (running the script should take less then 30 seconds)import requests# Requests is an elegant and simple HTTP library for Python, built for human beings.# Requests is the only Non-GMO HTTP library for Python, safe for human consumption.# Requests is not a built in module (does not come with the default python installation), so you will have to install it:# http://docs.python-requests.org/en/v2.9.1/# installing it for pyCharm is not so easy and takes a lot of troubleshooting (problems with pip's main version)# use conda/pip install requests insteadimport json# dict subclass for counting hashable objectsfrom collections import Counter#import heapqimport datetimeurl = 'https://api.namefake.com'# a "global" list object. TODO: try to make it "static" (local to the file)words = []###################################################################################### Calls the site http://www.namefake.com  100 times and retrieves random names# Examples for the format of the names from this site:# Dr. Willis Lang IV# Lily Purdy Jr.# Dameon Bogisich# Ms. Zora Padberg V# Luther Krajcik Sr.# Prof. Helmer Schaden            etc....#####################################################################################
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 177 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號