我有一个字典列表:
#NoEnv
#Warn
#SingleInstance Force
#UseHook
SetWorkingDir %A_ScriptDir%
SendMode Input
Global aKeysToFreeze := { LShift: false, a: false }, isFreezeOn := false
`::fToggleFreeze()
^`:: ; You can use this to check the logical state of the key
If GetKeyState("a")
msgbox Key is pressed.
else msgbox Key is not pressed.
return
fToggleFreeze() {
Local
Global aKeysToFreeze, isFreezeOn
If isFreezeOn { ; If there are frozen keys,
For sKeyName, isKeyFrozen in aKeysToFreeze {
Send % "{" sKeyName " Up}" ; send key up event for each key and
aKeysToFreeze[sKeyName] := false ; set the each key's frozen state to false
}
} else {
For sKeyName, isKeyFrozen in aKeysToFreeze
If GetKeyState(sKeyName, "P") ; If the key is physically pressed
aKeysToFreeze[sKeyName] := true ; set frozen state to true
}
isFreezeOn := !isFreezeOn ; Frozen mode toggle
}
*a::Send {Blind}{a DownR}
*LShift:: Send {Blind}{LShift DownR}
#If !aKeysToFreeze["a"] ; If the key is frozen, the key up hotkey is blocked
*a Up::Send {Blind}{a Up}
#If !aKeysToFreeze["LShift"]
*LShift Up::Send {Blind}{LShift Up}
#If
我需要像这样用相同的键连接所有字典:
bids_copy = [{'price': 1, 'quantity': 2}, {'price': 1, 'quantity': 5}, {'price': 2, 'quantity': 6}, {'price': 2, 'quantity': 2}]
bids_snapshot = []
我编写了一个无法按我希望的方式工作的函数:
print(bids_snapshot)
---> [{'price': 1, 'quantity': 7}, {'price': 2, 'quantity': 8}]
请帮忙,第三天我一直无法解决这个问题。