当前位置: 首页>>代码示例>>Python>>正文


Python Commons.format_unix_time方法代码示例

本文整理汇总了Python中inc.Commons.Commons.format_unix_time方法的典型用法代码示例。如果您正苦于以下问题:Python Commons.format_unix_time方法的具体用法?Python Commons.format_unix_time怎么用?Python Commons.format_unix_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inc.Commons.Commons的用法示例。


在下文中一共展示了Commons.format_unix_time方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_format_unix_time

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_unix_time [as 别名]
 def test_format_unix_time(self):
     unix1 = 0
     assert Commons.format_unix_time(unix1) == "1970-01-01 00:00:00"
     unix2 = 1000000000
     assert Commons.format_unix_time(unix2) == "2001-09-09 01:46:40"
     unix3 = 1234567890
     assert Commons.format_unix_time(unix3) == "2009-02-13 23:31:30"
开发者ID:joshcoales,项目名称:Hallo,代码行数:9,代码来源:testCommons.py

示例2: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_unix_time [as 别名]
 def run(self, line, user_obj, destination_obj=None):
     input_clean = line.strip().lower()
     url = "http://api.randomuser.me/0.6/?nat=gb&format=json"
     # Get api response
     json_dict = Commons.load_url_json(url)
     user_dict = json_dict['results'][0]['user']
     # Construct response
     name = (user_dict['name']['title'] + " " + user_dict['name']['first'] + " " + user_dict['name']['last']).title()
     email = user_dict['email']
     address = user_dict['location']['street'].title() + ", "
     address += user_dict['location']['city'].title() + ", "
     address += user_dict['location']['postcode']
     username = user_dict['username']
     password = user_dict['password']
     date_of_birth = Commons.format_unix_time(int(user_dict['dob']))
     phone_home = user_dict['phone']
     phone_mob = user_dict['cell']
     national_insurance = user_dict['NINO']
     pronoun = "he" if user_dict['gender'] == "male" else "she"
     pronoun_possessive = "his" if user_dict['gender'] == "male" else "her"
     if input_clean not in ["more", "full", "verbose", "all"]:
         output = "I have generated this person: Say hello to " + name + ". "
         output += pronoun.title() + " was born at " + date_of_birth + "."
         return output
     output = "I have generated this person: Say hello to " + name + ". "
     output += pronoun.title() + " was born at " + date_of_birth + " and lives at " + address + ". "
     output += pronoun.title() + " uses the email " + email + ", the username \"" + username + \
         "\" and usually uses the password \"" + password + "\". "
     output += pronoun_possessive.title() + " home number is " + phone_home + " but "
     output += pronoun_possessive + " mobile number is " + phone_mob + ". "
     output += pronoun_possessive + " national insurance number is " + national_insurance + "."
     return output
开发者ID:,项目名称:,代码行数:34,代码来源:

示例3: run

# 需要导入模块: from inc.Commons import Commons [as 别名]
# 或者: from inc.Commons.Commons import format_unix_time [as 别名]
 def run(self, event):
     input_clean = event.command_args.strip().lower()
     url = "https://api.randomuser.me/0.6/?nat=gb&format=json"
     # Get api response
     json_dict = Commons.load_url_json(url)
     user_dict = json_dict['results'][0]['user']
     # Construct response
     name = "{} {} {}".format(user_dict['name']['title'],
                              user_dict['name']['first'],
                              user_dict['name']['last']).title()
     email = user_dict['email']
     address = "{}, {}, {}".format(user_dict['location']['street'].title(),
                                   user_dict['location']['city'].title(),
                                   user_dict['location']['postcode'])
     username = user_dict['username']
     password = user_dict['password']
     date_of_birth = Commons.format_unix_time(int(user_dict['dob']))
     phone_home = user_dict['phone']
     phone_mob = user_dict['cell']
     national_insurance = user_dict['NINO']
     pronoun = "he" if user_dict['gender'] == "male" else "she"
     pronoun_possessive = "his" if user_dict['gender'] == "male" else "her"
     if input_clean not in ["more", "full", "verbose", "all"]:
         output = "I have generated this person: Say hello to {}. {} was born at {}.".format(name,
                                                                                             pronoun.title(),
                                                                                             date_of_birth)
         return event.create_response(output)
     output = "I have generated this person: Say hello to {}. " \
              "{} was born at {} and lives at {}. " \
              "{} uses the email {}, the username {} and usually uses the password \"{}\". " \
              "{} home number is {} but {} mobile number is {}. " \
              "{} national insurance number is {}.".format(name,
                                                           pronoun.title(), date_of_birth, address,
                                                           pronoun.title(), email, username, password,
                                                           pronoun_possessive.title(), phone_home,
                                                           pronoun_possessive, phone_mob,
                                                           pronoun_possessive.title(), national_insurance)
     return event.create_response(output)
开发者ID:joshcoales,项目名称:Hallo,代码行数:40,代码来源:Random.py


注:本文中的inc.Commons.Commons.format_unix_time方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。