此def中的无效语法错误是什么?

问题描述 投票:0回答:1

我正在尝试使用以Python编写的this Anki add-on

但是,在Anki 2.1启动时,返回错误。

有人可以快速浏览链接中的短代码并发现错误吗?也许与python的最新更新不兼容?

# Anki 2.0 addon
# Author EJS 
# https://eshapard.github.io/
#
# Sets the learning steps sequence of each deck options group.
from anki.hooks import addHook
from aqt import mw
#from aqt.utils import showInfo
#import time

ignoreList = ['Default', 'OnHold', 'Parent Category'] #Deck options groups to ignore

# run this on profile load
def updateLearningSteps():
   #find all deck option groups
   dconf = mw.col.decks.dconf
   #cycle through them one by one
   for k in dconf:
       if dconf[k]["name"] not in ignoreList:
           #showInfo(dconf[k]["name"])
           ease = dconf[k]["new"]["initialFactor"]/1000.0
           #create learning steps
           tempList = [15]
           for i in range(10):
               l = int(1440*ease**i)
               if l < 28800:
                   tempList.append(l)
               else:
                   gradInts = [(l/1440),(l/1440)]
                   break
           #showInfo(str(tempList))
           #showInfo(str(gradInts))
           mw.col.decks.dconf[k]["new"]["delays"] = tempList
           mw.col.decks.dconf[k]["new"]["ints"] = gradInts
           mw.col.decks.save(mw.col.decks.dconf[k])
   mw.res
et()

# add hook to 'profileLoaded'
addHook("profileLoaded", updateLearningSteps)

这是错误:https://user-images.githubusercontent.com/52420923/66923073-ba2df980-f017-11e9-8b66-c8799db29850.png

python syntax syntax-error
1个回答
0
投票

您发布的代码与错误不符。错误的def updateLearningSteps()在行尾没有冒号。这确实是语法错误。

© www.soinside.com 2019 - 2024. All rights reserved.