一個(gè)打叉的圖,一個(gè)透明底的框圖,絕對(duì)定位
我不知道你們后臺(tái)是用語言寫的,一般跨域是后臺(tái)配置的,這個(gè)是你請(qǐng)求后臺(tái)入口文件的前綴而已,前臺(tái)在你的config文件里配置,
配置文件
有3個(gè),一個(gè)開發(fā)模式下的前綴配置
第二屬于映射表,具體你可以去研究下
第三個(gè)是生產(chǎn)模式下配置,和第一基本一致,前綴是正式的
第一個(gè)文件里的內(nèi)容
第二個(gè)文件內(nèi)容
在main.js里設(shè)置全局變量這樣你可以在子頁(yè)面都可以使用
在你html中增加
<script>
alert('hello world!');
</script>
就可以彈出來'hello world!'對(duì)話框。
你應(yīng)該是初學(xué)者,自己多百度,多練習(xí)。我這邊就不講太多知識(shí)了。
cli模式下的php.ini配置,部分會(huì)被覆蓋。參考官方網(wǎng)址(覆蓋 php.ini 設(shè)置選項(xiàng)):http://php.net/manual/zh/feat...
實(shí)現(xiàn)key-value咯,參見https://www.zhihu.com/question/30527705。
當(dāng)然時(shí)間多的話你可以對(duì)比各種查找樹實(shí)現(xiàn)key-value存儲(chǔ)結(jié)構(gòu)的存儲(chǔ)和查詢效率,搞個(gè)benchmark,然后就可以寫一篇博客。
你應(yīng)該先把別人的項(xiàng)目fork到你的倉(cāng)庫(kù),然后你在git clone 你自己的倉(cāng)庫(kù)地址
可以監(jiān)聽onload,iframe有跳轉(zhuǎn)就會(huì)觸發(fā)。
var iframe = document.getElementById('index');
iframe.onload = function() {
console.log(123)
}
python 的文檔:https://docs.python.org/2/lib... 顯示:
The built-in sorted() function is guaranteed to be stable. A sort is stable if it guarantees not to change the relative order of elements that compare equal — this is helpful for sorting in multiple passes (for example, sort by department, then by salary grade).
即,不改變比較相等的元素的相對(duì)位置。根據(jù)問題給出的 key,237 和 100 是“相等”的,所以它們之間的相對(duì)關(guān)系不會(huì)變化,即 237 在 100 之前。
把你想保留的數(shù)據(jù)持久化成 Query String 放在 URL 中。
,先npm個(gè)插件extract-text-webpack-plugin;里面的名字你看著改就行了
Lock.acquire([ blocking ] )
獲取鎖定,阻止或不阻止。
當(dāng)調(diào)用阻塞參數(shù)設(shè)置為True(默認(rèn))時(shí),阻塞,直到鎖定解鎖,然后將其設(shè)置為鎖定并返回True。
當(dāng)調(diào)用阻塞參數(shù)設(shè)置為False,不要阻塞。如果阻塞設(shè)置的呼叫True會(huì)阻塞,F(xiàn)alse 立即返回; 否則,將鎖設(shè)置為鎖定并返回True。
所以你可以寫成 if _from.lock.acquire(False): 不阻塞
那你只能js判斷了,當(dāng)在6后面的時(shí)候,動(dòng)態(tài)設(shè)置box-item的橫向滾動(dòng)值
已經(jīng)找到問題了, 因?yàn)樵赾ss文件夾下我自己創(chuàng)建了二級(jí)文件夾,但是二級(jí)文件夾沒有權(quán)限 ,所以導(dǎo)致一直是404 ??墒呛芤苫鬄樯稕]報(bào)”沒權(quán)限“問題 。:)
每次 bind() 都會(huì)生成一個(gè)新的函數(shù)返回出來,所以 a.bind(o) !== a.bind(o)
有的字符就是空白,比如回車,tab,有的顯示成文號(hào),可能是你電腦上沒有這個(gè)字符集吧。
for in會(huì)把[__ob__: Observer]當(dāng)成一個(gè)子項(xiàng)進(jìn)行遍歷,所以res.data.list長(zhǎng)度不是4而是5。
解決方法:
1、for in 里面過濾掉:
for(let i in obj){
if(typeof obj[i] == "undefined") return;
}
2、不要使用for in 方法,改為:
for(let i = 0 ; i < obj.length; i++){
}不需要桌面的話可以只下載minimal版本的,后續(xù)需要什么就聯(lián)網(wǎng)安裝,如果是新手的話建議下載DVD或者everything版本的,里面自帶的軟件比較多,也有圖形化界面
使用jsonp返回的數(shù)據(jù)格式要相應(yīng)的調(diào)整下,并非json格式。大致說一下java如何返回使用jsonp請(qǐng)求的數(shù)據(jù)格式吧!
// jsonStr:json格式的數(shù)據(jù)
return "jsonpCallback(" + jsonStr+ ");" ;
返回使用jsonp請(qǐng)求的數(shù)據(jù)格式大致應(yīng)該是這樣的:
jsonpCallback({
"url": "1234",
"name": "abcd"
})
多說一句:如果您使用jsonp單單是為了跨域的話,推薦您使用跨域資源共享 CORS 來跨域,推薦您看下阮一峰大神的博文:http://www.ruanyifeng.com/blo...
我也剛看,試了好久,初步知道怎么回事了.
先回答你的兩個(gè)問題:
1、setDaemon所綁定的都是主線程,都是一樣的,即運(yùn)行py文件第一次創(chuàng)建的那個(gè)線程(也是主進(jìn)程),有且只有一個(gè)
2、queue.join()如果單獨(dú)使用會(huì)被無限掛起,字面翻譯為等待隊(duì)列為空,再執(zhí)行別的操作.但是他等待的隊(duì)列不是我們創(chuàng)建的aqueue,而是一個(gè)與aqueue長(zhǎng)度相等的一個(gè)"需要完成的子線程"隊(duì)列,他判斷的很可能是這個(gè)列表,當(dāng)這個(gè)列表為空時(shí)queue.join()才成立,所以如樓上的那位所說queue.join()要結(jié)合aqueue.task_done()函數(shù)來使用,aqueue.task_done()的意思是每task_done一次 就從"需要完成的子線程"隊(duì)列里刪掉一個(gè)元素,這樣在最后join的時(shí)候根據(jù)隊(duì)列長(zhǎng)度是否為零來判斷隊(duì)列是否結(jié)束,aqueue.task_done()用在子線程函數(shù)中,這樣queue.join()才知道完成了多少個(gè)子線程,才不會(huì)無限掛起,也就是為什么你沒退出的原因
但是你的程序也有問題:
主要的問題是,守護(hù)線程機(jī)制:主線程運(yùn)行完畢去結(jié)束子線程時(shí),由于有大量的子線程還在time.sleep(5),結(jié)束這些子線程會(huì)觸發(fā)異常:
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads
Thread 0x000019cc (most recent call first):
File "test.py", line 13 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
這是因?yàn)?
下面的一些說法是錯(cuò)誤的,可以看我后面的補(bǔ)充,這里就不改了,是一種猜測(cè),但是應(yīng)該確實(shí)不是這樣
喂不飽的子線程:你aqueue.put(i)了是10個(gè)元素,但是卻運(yùn)行了20個(gè)子線程來"吃"這10個(gè)元素,又因?yàn)檫@20個(gè)線程都是守護(hù)進(jìn)程,當(dāng)10個(gè)吃飽了,這個(gè)10個(gè)卡在了item = aqueue.get()等待接受元素,另外的那些很有可能卡在了time.sleep(5)上,而主線程運(yùn)行完畢,準(zhǔn)備結(jié)束所有的守護(hù)進(jìn)程,我判斷,結(jié)束卡在item = aqueue.get()的守護(hù)進(jìn)程不會(huì)報(bào)錯(cuò),而結(jié)束其他程序,如time.sleep會(huì)觸發(fā)異常,這也是為啥樓上那位吧你的for i in range(20):改成了for i in range(1):的原因.
還有兩種退出的方式:
1、是在子線程里判斷隊(duì)列是否為空:
if aqueue.empty() == True:
break
為空就退出
2、主線程通過queue向子線程發(fā)送退出命令
其實(shí)這里一般用pipe管道的,Queue隊(duì)列不好針對(duì)特定的線程進(jìn)行退出操作,大概的偽碼為:
主線程:
aqueue.put('quit')
子線程""
item = aqueue.get()
if item == 'quit':
return
else:
# "do something"
所以多進(jìn)程,多線程還是要控制好程序邏輯,控制好調(diào)度.
我沒用過守護(hù)進(jìn)程,我一般用的是普通的用戶進(jìn)程,這樣主線程跑完會(huì)等待所有子線程運(yùn)行完畢再結(jié)束
其實(shí)還沒完=_=:
后面的都是我的猜測(cè),算是附加的,選修:
這程序的細(xì)節(jié)也值得我們關(guān)注:
這程序如果真去實(shí)踐的話很容易炸,以下都是我的猜測(cè)
如上所述,我們修改程序,注意注釋
import queue
import threading
import time
aqueue = queue.Queue()
# 發(fā)送了0到9的十個(gè)數(shù)據(jù)
for i in range(10):
aqueue.put(i)
def worker():
while True:
# 輸出當(dāng)前線程,和主線程(可以看到主線程都一樣)
print('thread %s is running...\nmain_thread %s is running...\n\n' % (threading.current_thread().name,threading.main_thread()))
time.sleep(1)
item = aqueue.get()
print(item)
aqueue.task_done()
print('thread end')
n = 1
"""注意這!!!!!!!!!!!!!!!!!!"""
# 運(yùn)行了10個(gè)線程來處理這十個(gè)數(shù)據(jù)
for i in range(10):
print("run thread Counts: ",n)
n += 1
a = threading.Thread(target = worker)
a.setDaemon(True)
a.start()
aqueue.join()
print('after to do')
print('end')
10個(gè)數(shù)據(jù)10個(gè)線程,time.cleep(5)秒結(jié)果會(huì)怎么樣?運(yùn)行正常?
很不幸運(yùn)的炸了23333333
有一定的幾率報(bào)錯(cuò),和上面一樣:
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads
Thread 0x0000063c (most recent call first):
File "test.py", line 13 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
我電腦上大部分運(yùn)行正常,只有幾次會(huì)這樣,為什么會(huì)這樣?
換成10個(gè)數(shù)據(jù)9個(gè)線程就不會(huì)出錯(cuò)了
我猜測(cè)的情況是,初步認(rèn)為:
直接看完整的輸出,注意看有注釋的地方:
run thread Counts: 1
thread Thread-1 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 2
thread Thread-2 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 3
thread Thread-3 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 4
thread Thread-4 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 5
thread Thread-5 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 6
thread Thread-6 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 7
thread Thread-7 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 8
thread Thread-8 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 9
thread Thread-9 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
run thread Counts: 10
thread Thread-10 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
0
1
3
4
thread end
thread end
5
2
thread Thread-2 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
thread end
thread end
thread end
thread Thread-3 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
thread end
thread Thread-4 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
thread Thread-1 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
thread Thread-5 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
6
8
thread Thread-6 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
thread end
thread end
thread Thread-7 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
7
9
thread Thread-9 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
"""到這里主線程已經(jīng)完畢"""
thread end
after to do
"""
這里其實(shí)系統(tǒng)在調(diào)用守護(hù)線程的結(jié)束程序來結(jié)束所有子線程
"""
"""但是在結(jié)束守護(hù)進(jìn)程程序后,又運(yùn)行了一個(gè)不該運(yùn)行的子線程,這就是為什么會(huì)報(bào)錯(cuò)的原因"""
thread Thread-10 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
end
thread end
thread Thread-8 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
Fatal Python error: could not acquire lock for <_io.BufferedWriter name='<stdout>'> at interpreter shutdown, possibly due to daemon threads
Thread 0x00000424 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x00000f04 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x0000165c (most recent call first):
File "test.py", line 13 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x000018b0 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x00000db4 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x00001a88 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x0000111c (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x0000177c (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x000008e4 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Thread 0x00001788 (most recent call first):
File "test.py", line 14 in worker
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 864 in run
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 916 in _bootstrap_inner
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36\lib\threading.py", line 884 in _bootstrap
Current thread 0x00001a18 (most recent call first):
看主要的幾句
"""到這里主線程已經(jīng)完畢"""
thread end
after to do
"""
這里其實(shí)系統(tǒng)在調(diào)用守護(hù)線程的結(jié)束程序來結(jié)束所有子線程
"""
"""但是在結(jié)束守護(hù)進(jìn)程程序后,又運(yùn)行了一個(gè)不該運(yùn)行的子線程,這就是為什么會(huì)報(bào)錯(cuò)的原因"""
thread Thread-10 is running...
main_thread <_MainThread(MainThread, started 6680)> is running...
end
thread end
先這樣吧,可以自己運(yùn)行下程序看看
看了另一個(gè)答主的,使用了a.join()也是一種選擇
改成發(fā)送10個(gè)數(shù)據(jù),用9個(gè)線程跑,效率是最高的(理論)
import queue
import threading
import time
aqueue = queue.Queue()
# 發(fā)送了0到9的十個(gè)數(shù)據(jù)
for i in range(10):
aqueue.put(i)
def worker():
while True:
# 輸出當(dāng)前線程,和主線程(可以看到主線程都一樣)
print('thread %s is running...\nmain_thread %s is running...\n\n' % (threading.current_thread().name,threading.main_thread()))
time.sleep(5)
item = aqueue.get()
print(item)
aqueue.task_done()
print('thread end')
n = 1
"""注意這!!!!!!!!!!!!!!!!!!"""
for i in range(9):
print("run thread Counts: ",n)
n += 1
a = threading.Thread(target = worker)
a.setDaemon(True)
a.start()
aqueue.join()
print('after to do')
print('end')
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問,美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。