context對象在Cython下的傳遞 [金字塔]
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">def handle_bar(context)是可以正常運(yùn)行的:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">但現(xiàn)在需要用:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">settimer來自己控制,實(shí)際運(yùn)行的程序是:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">def run(context),如果不編譯也是正常的,但是編譯以后: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">settimer(run,1000)這句代碼無法帶入:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">context參數(shù),報(bào)一個(gè)錯(cuò)誤,說是要求是str的類型,但實(shí)際上是: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">context類型: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">有什么辦法解決這個(gè)問題:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">問題在于:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">settimer和:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">killtimer要求函數(shù)必須有:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">context參數(shù),但是帶參數(shù)編譯過后的pyd又報(bào)類型不對:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">Argument 'context' has incorrect type (expected str, got context):="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">我在想是否能夠指定一下:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">context這個(gè)參數(shù)的類型?: none; text-indent: 0px; letter-spacing: normal; font-family: Verdana; font-size: 14px; font-variant: normal; word-spacing: 0px; display: inline=" inline"="" !important;="" white-space:="" normal;="" orphans:="" 2;="" float:="" none;="" -webkit-text-stroke-width:="" 0px;="" background-color:="" rgb(255,="" 255,="" 255);"="">
: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">settimer 設(shè)定計(jì)時(shí)器—定時(shí)觸發(fā):="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">函數(shù)原型:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: inherit; word-spacing: 0px;">
: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;">設(shè)定計(jì)時(shí)器—定時(shí)觸發(fā),僅"paper_trading"模式有效:="" -webkit-text-stroke-width:="" white-space:="" word-spacing:="" 0px;"="">
注意:function函數(shù)一定要包含(并且只能包含)context
?
網(wǎng)友回復(fù):
還有一個(gè)辦法就是自己寫一個(gè)死循環(huán),這樣可以運(yùn)行,但是退出的時(shí)候怎么結(jié)束這個(gè)進(jìn)程?def init(context):
??? while True:
??????? run(context)
??????? time.sleep(1)
網(wǎng)友回復(fù):
?
?
還有一個(gè)辦法就是自己寫一個(gè)死循環(huán),這樣可以運(yùn)行,但是退出的時(shí)候怎么結(jié)束這個(gè)進(jìn)程?def init(context):
??? while True:
??????? run(context)
??????? time.sleep(1)
?
import time
definit(context):
??? # 設(shè)置計(jì)時(shí)器
??? settimer(msg,10)
defmsg(context):
??? #輸出現(xiàn)在時(shí)間
??? a = time.asctime( time.localtime(time.time()) )
??? print(a)
#退出程序后殺死計(jì)時(shí)器
defexit(context):
??? killtimer(msg)
?
?
?
?
不是很明白范例里這個(gè)不是可以的嗎?退出時(shí)候殺死計(jì)時(shí)器
有思路,想編寫各種指標(biāo)公式,交易模型,選股公式,還原公式的朋友
可聯(lián)系技術(shù)人員 QQ: 262069696 或微信號:cxh99cxh99 進(jìn)行 有償收費(fèi) 編寫!
(怎么收費(fèi),代編流程等詳情請點(diǎn)擊閱讀!)
(注:由于人數(shù)限制,QQ或微信請選擇方便的一個(gè)聯(lián)系我們就行,加好友時(shí)請簡單備注下您的需求,否則無法通過。謝謝您!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容