本文整理汇总了Python中inc.Commons.Commons.read_file_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.read_file_to_list方法的具体用法?Python Commons.read_file_to_list怎么用?Python Commons.read_file_to_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inc.Commons.Commons
的用法示例。
在下文中一共展示了Commons.read_file_to_list方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import read_file_to_list [as 别名]
def run(self, line, user_obj, destination_obj=None):
"""WH40K Thought for the day. Format: thought_for_the_day"""
thought_list = Commons.read_file_to_list('store/WH40K_ToTD2.txt')
rand = Commons.get_random_int(0, len(thought_list) - 1)[0]
if thought_list[rand][-1] not in ['.', '!', '?']:
thought_list[rand] += "."
return '"' + thought_list[rand] + '"'
示例2: test_read_file_to_list
# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import read_file_to_list [as 别名]
def test_read_file_to_list(self):
data = Commons.read_file_to_list("test/inc/test.txt")
assert len(data) == 5
assert data[0] == "test1"
assert data[1] == "test2"
assert data[2] == "test3"
assert data[3] == "test4"
assert data[4] == "test5"
示例3: run
# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import read_file_to_list [as 别名]
def run(self, event):
word_list = Commons.read_file_to_list('store/ouija_wordlist.txt')
num_words = Commons.get_random_int(1, 3)[0]
rand_words = Commons.get_random_choice(word_list, num_words)
output_string = "I'm getting a message from the other side... {}.".format(" ".join(rand_words))
return event.create_response(output_string)
示例4: load_thought_list
# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import read_file_to_list [as 别名]
def load_thought_list(self):
self.thought_list = Commons.read_file_to_list('store/WH40K_ToTD2.txt')