本文整理汇总了Python中Helper.Helper.daysAsPrettyLength方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.daysAsPrettyLength方法的具体用法?Python Helper.daysAsPrettyLength怎么用?Python Helper.daysAsPrettyLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper.Helper
的用法示例。
在下文中一共展示了Helper.daysAsPrettyLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookupWord
# 需要导入模块: from Helper import Helper [as 别名]
# 或者: from Helper.Helper import daysAsPrettyLength [as 别名]
def lookupWord(self, args):
word = args[0]
if not self.wordDict.exists(word):
print('Invalid word')
return
print(word + ': ')
print('First usage: ' + str(self.wordDict.getFirstOccurrence(word)))
print('Last usage: ' + str(self.wordDict.getLastOccurrence(word)))
total_uses = self.wordDict.getCount(word)
total_days_used = self.wordsPerDayDict.getCount(word)
total_number_of_days = len(self.wordCountOfEntriesDict)
print('Total usages: ' + str(total_uses))
print('Total days with at least one usage: ' + str(total_days_used))
length = (self.wordDict.getLastOccurrence(word) - self.wordDict.getFirstOccurrence(word)).days
print('Length from first use to last: ' + Helper.daysAsPrettyLength(length))
print('Average usages per day: ' + str(float(total_uses) / length))
print('Percentage of days with at least one useage: ' + str(round(float(total_days_used) / total_number_of_days * 100, 2)) + '%')