在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/ Python問答
還吻 回答

多線程應該是這么操作的

#coding:utf-8
from multiprocessing.dummy import Pool #這里使用協(xié)程而不是線程,根據自己的情況選擇,協(xié)程可以開更多的thread
import time


def callback(result): # 回調
    print result
def dealer(name): # 處理函數
    time.sleep(3) # do some heavy job
    return name

pool = Pool(20) # 準備一個20個thread的線程池
p = ["task1","task2","taskn"] # n個任務
for task in p:
    pool.apply_async(dealer,(task,),callback=callback)
pool.close()
pool.join()

關鍵在join方法,這個方法是用來阻塞進程,保證多線程執(zhí)行完畢的,你每循環(huán)到一個任務,就初始化一個線程池,并且阻塞到這個任務結束,其他的任務并沒有同時開始執(zhí)行,到下次循環(huán)才會開始另一個任務.
Pool只應該初始化一次,你的代碼里,在for循環(huán)中反復初始化Pool,并且調用join方法阻塞了程序,實際上你的代碼還是單線程在跑.
把我這個例子寫成你的風格就是

#coding:utf-8
from multiprocessing.dummy import Pool #這里使用協(xié)程而不是線程,根據自己的情況選擇,協(xié)程可以開更多的thread
import time


def callback(result): # 回調
    print result
def dealer(name): # 處理函數
    time.sleep(3) # do some heavy job
    return name


p = ["task1","task2","taskn"] # n個任務
for task in p:
    pool = Pool(20) # 準備一個20個thread的線程池
    pool.apply_async(dealer,(task,),callback=callback)
    pool.close()
    pool.join()

這兩段代碼都可以直接復制出來跑,你感受一下就明白了.

臭榴蓮 回答

pypdf不支持替換,只支持:

extracting document information (title, author, ...),
splitting documents page by page,
merging documents page by page,
cropping pages,
merging multiple pages into a single page,
encrypting and decrypting PDF files.

可以曲線救國,先轉word再改內容:
http://blog.csdn.net/zyc12156...

陌南塵 回答

取 host 頭,判斷后作 301 返回。

短嘆 回答

gevent.joinall
英文解釋:Wait for the greenlets to finish.
中文解釋:等待協(xié)程結束

例子:


In [1]: import gevent

In [2]: def solve(i):
   ...:     return i
   ...: 

In [3]: threads = [gevent.spawn(solve,i) for i in range(1,10)]

In [4]: gevent.joinall(threads)
Out[4]: 
[<Greenlet at 0x10eaa8b90>,
 <Greenlet at 0x10eaa8d70>,
 <Greenlet at 0x10eaa8e10>,
 <Greenlet at 0x10eaa8550>,
 <Greenlet at 0x10eaa8a50>,
 <Greenlet at 0x10eaa8690>,
 <Greenlet at 0x10eaa8eb0>,
 <Greenlet at 0x10eaa8f50>,
 <Greenlet at 0x10eaa8c30>]

In [5]: print([t.value for t in threads])
[1, 2, 3, 4, 5, 6, 7, 8, 9]
傻丟丟 回答

我換了種做法,

每種查詢類命令比如 ps/ss, 查詢后, 一般都是做grep 操作

我們限制用戶執(zhí)行的命令種類, 比如 ps/ss, 用戶post時, 選擇執(zhí)行的命令類型,
并只能添加過濾關鍵字, 格式類似于

<cmd> key1 key2 key3

依次校驗 key1..., 限制key只能是單詞或包含有限的特殊字符, 拼接執(zhí)行時不會對系統(tǒng)產生影響的,
這類校驗就比較簡單了, 一個正則就可以確定,

如下

word_re = re.compile(r'([a-zA-Z0-9\.]+)')

greps = []
for key in keys:
    matches = word_re.findall(key)
    # key 包含特殊字符
    if len(matches) == 0 or len(matches) > 1 or matches[0] != key:
        return send_msg(from_user, f'進程關鍵字包含特殊字符: {key}')
    greps.append(f'grep -i {key}')

cmd = f'ps -ef | {"|".join(greps)}'

在拼接命令后, 最終的執(zhí)行格式如下

ps -ef | grep key1 | grep key2 | grep key3

這樣就達到了在用戶post關鍵字后校驗命令僅會查詢, 不會對系統(tǒng)產生影響

款爺 回答

如果只是從列表中去掉的話

arr = map(lambda x:x.strip(),arr)
arr = [e for e in arr if e]

當然得根據具體的需求,如果只是題主提供的那種字符串列表,這種方式就夠了

風清揚 回答

同一個路由不會主動再次觸發(fā),試試:

{
    path: 'order/list/:type', 
    component: OrderListComponent,
    canActivate:[AuthService],
    runGuardsAndResolvers:'paramsChange'
}

這樣在你:type路由參數變化時會執(zhí)行相關路由事件??梢栽诮M件類里面監(jiān)聽到

this.router.events.subscribe((e: any) => {
   ...
})
雨萌萌 回答
推送所有tag :git push --tags

附git常用命令

查看文件狀態(tài) :git status
切換分支 :git checkout [分支名]
新增文件 :git add [文件名]
新增所有文件 :git add -all
刪除文件 :git rm [文件名]
提交代碼到本地倉庫 :git commit -m "說明"
將本地倉庫代碼推送到遠程 :git push

代碼回滾:(push前一定檢查好,不然回滾有很多坑)
查看日志 :git log
回滾到上一個版本 :git reset --hard HEAD^
到指定版本 :git reset --hard [commit hash]

創(chuàng)建分支
創(chuàng)建分支 :git checkout -b [分支名]
刪除分支 :git branch -d [分支名]
推送分支到遠程 :git push origin [分支名]
關聯(lián)遠程分支 :git push --set-upstream origin [分支名]

合并分支代碼
整個分支合并:git checkout [被合并的分支名]
根據[需求|commit hash]合并:

  單個版本號合并:git cherry-pick [commit hash]
  多個版本號合并:git rebase   (好幾種用法,自行百度)

對發(fā)布分支打tag(tag名請跟發(fā)布分支名保持一致)
打tag :git tag -a [tag名] -m "此次tag備注"
推送所有tag :git push --tags
刪除tag :git tag -d [tag名]

懶洋洋 回答

Boss_shujuyuan_url少了個括號。

Boss_shujuyuan_url = 'http://boss.yunzhangcaijing.com/Grab/Data/dataSource.html?catid=950&website=&title=&channel_column=&crawl_start={}&crawl_end=&status=-123&star=-1&export_action=0&pagesize=50'.format(time.strftime('%Y-%m-%d 00:00:00'), time.localtime())
爆扎 回答

客戶端可以實現監(jiān)聽下載完成的回調,啟動下載的東西,因為客戶端有文件資源的權限
網頁不行的,因為web沒有直接的文件資源的權限的(安全方面考慮,沒有人希望一個網頁可以讀取自己手機的文件)

寫榮 回答

看描述,似乎含有「列表名字」的行總是以>開頭的?
那么兩個>之間的內容就是列表名字 + 行內容了吧。

代碼思路如下,沒有實際跑過:

current_content = ''
current_name = ''

for line in f:
    line = line.strip()
    if line.startswith('>'):  # 判斷開頭是否為 >
        name = line[1:]       # 去掉 >
        if current_content:
            # 處理當前的內容
            r = ratio(current_content)
            count.append((current_name, r))  # 將 tuple 插入 list, 此時 current_name 尚未更新
        current_name = name  # 更新 current_name
        current_content = '' # 重置 current_content, 準備記錄新的內容
    else:
        current_content += line
心夠野 回答
  1. 假設你用QQ的10000申請接入和用10001接入的QQ互聯(lián),只要配置一下APP ID和APP KEY就可以切換管理員賬號了
  2. 如果你問的是為什么我用的是10000申請的QQ互聯(lián),別的QQ可以登錄,你需要了解oauth2的流程,QQ互聯(lián)也有接口文檔使用Authorization_Code獲取Access_Token

    1. 跳轉到QQ登錄頁面,其中攜帶回調地址
    2. 用戶登錄授權
    3. 登錄成功后,回調地址+授權碼Code
    4. 發(fā)送通過授權碼獲取access_token請求
    5. 使用access_token去獲取其它信息
菊外人 回答

route的最外層組件必須是router

朽鹿 回答

iconbitmap()需要的參數是圖標的地址.

如果你的python.ico文件是放在當前目錄, 直接root.iconbitmap('python.ico')是沒問題的.
如果python.ico文件是放在別的目錄, 比如/home/user/foo/python.ico, 那就用絕對路徑吧, root.iconbitmap('/home/user/foo/python.ico').

總之, 一定要確定你的文件路徑中存在python.ico這個文件.

小曖昧 回答

name 命名有問題。變量Role是什么?

爆扎 回答

去看看它的源碼應該會有所幫助

大濕胸 回答

都提示你了,Windows 7 Service Pack 1 and all applicable updates are required.
你的 win7 沒升級 SP1 等更新包。