當前位置: 首頁>>代碼示例>>Python>>正文


Python time.second方法代碼示例

本文整理匯總了Python中time.second方法的典型用法代碼示例。如果您正苦於以下問題:Python time.second方法的具體用法?Python time.second怎麽用?Python time.second使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在time的用法示例。


在下文中一共展示了time.second方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: saveImage

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def saveImage():
	keepDiskSpaceFree(config.diskSpaceToReserve)
	time = datetime.datetime.now()
	filenameFull = config.filepath + config.filenamePrefix + "-%04d%02d%02d%02d%02d%02d" % (time.year, time.month, time.day, time.hour, time.minute, time.second)+ "." + config.fileType
	
	# save onto webserver
	filename = "/var/www/temp.jpg"
	subprocess.call("sudo raspistill -w "+ str(config.saveWidth) +" -h "+ str(config.saveHeight) + " -t 1 -n -vf -e " + config.fileType + " -q 15 -o %s" % filename, shell=True)
	print "Captured image: %s" % filename

	theSpeech = recognizeFace(filename,filenameFull)
	if len(theSpeech)>2:
		print theSpeech
		saySomething(theSpeech,"en")
		config.lookForFaces = 0


# Keep free space above given level 
開發者ID:schollz,項目名稱:rpi_ai,代碼行數:20,代碼來源:visual_cortex.py

示例2: updateTime

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def updateTime(mc, clockCentre, lastTime, time):
    #draw hour and minute hand
    if (lastTime.minute != time.minute):
        #clear hour hand
        drawHourHand(mc, clockCentre, lastTime.hour, lastTime.minute, 'air')
        #new hour hand
        drawHourHand(mc, clockCentre, time.hour, time.minute, 'dirt')
        
        #clear hand
        drawMinuteHand(mc, clockCentre, lastTime.minute, 'air')
        #new hand
        drawMinuteHand(mc, clockCentre, time.minute, 'STONE')

    #draw second hand
    if (lastTime.second != time.second):
        #clear hand
        drawSecondHand(mc, clockCentre, lastTime.second, 'AIR')
        #new hand
        drawSecondHand(mc, clockCentre, time.second, 'WOOD_PLANKS') 
開發者ID:wensheng,項目名稱:JuicyRaspberryPie,代碼行數:21,代碼來源:minecraft_clock.py

示例3: line_two

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def line_two(self, language=None):
        """Returns the second line of the address, including the city,
        state and zip code."""
        output = ""
        #if hasattr(self, 'sublocality') and self.sublocality:
        #    output += str(self.sublocality) + ", "
        if hasattr(self, 'sublocality_level_1') and self.sublocality_level_1:
            output += str(self.sublocality_level_1) + ", "
        output += str(self.city)
        if hasattr(self, 'state') and self.state:
            output += ", " + str(self.state)
        if hasattr(self, 'zip') and self.zip:
            output += " " + str(self.zip)
        elif hasattr(self, 'postal_code') and self.postal_code:
            output += " " + str(self.postal_code)
        return(output) 
開發者ID:jhpyle,項目名稱:docassemble,代碼行數:18,代碼來源:util.py

示例4: _combine_date_time

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def _combine_date_time(d, t):
    if (d is not None) and (t is not None):
        return datetime(d.year, d.month, d.day, t.hour, t.minute, t.second)
    return None 
開發者ID:eamigo86,項目名稱:graphene-django-extras,代碼行數:6,代碼來源:date.py

示例5: get_time_string

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def get_time_string():
    '''

    Returns current time in day_month_HH-MM-SS/ format

    '''
    time = datetime.now()
    name = (str(time.day) + '_' + str(time.month) + '_%02d' % time.hour +
            '-%02d' % time.minute + '-%02d' % time.second + '/')
    return name 
開發者ID:Vaan5,項目名稱:piecewisecrf,代碼行數:12,代碼來源:train.py

示例6: drawClock

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def drawClock(mc, clockCentre, radius, time):
    drawCircle(mc, clockCentre.x, clockCentre.y, clockCentre.z, radius, 'DIAMOND_BLOCK')
    drawHourHand(mc, clockCentre, time.hour, time.minute, 'DIRT')
    drawMinuteHand(mc, clockCentre, time.minute, 'STONE')
    drawSecondHand(mc, clockCentre, time.second, 'WOOD_PLANKS') 
開發者ID:wensheng,項目名稱:JuicyRaspberryPie,代碼行數:7,代碼來源:minecraft_clock.py

示例7: test_bad_every

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def test_bad_every(self):
        with self.assertRaises(ValueError):
            Tab('a').every(second=1, minute=3)
            # Cron().schedule(Tab('a').every(second=1, minute=3)) 
開發者ID:robdmc,項目名稱:crontabs,代碼行數:6,代碼來源:test_all.py

示例8: test_base_case

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def test_base_case(self):
        cron = Cron()
        cron.schedule(
            Tab('two_sec', verbose=False).every(seconds=2).run(time_logger, 'two_sec'),
            Tab('three_sec', verbose=False).every(seconds=3).run(time_logger, 'three_sec')
        )
        with PrintCatcher(stream='stdout') as stdout_catcher:
            cron.go(max_seconds=6)

        base_lookup = {
            'three_sec': 3,
            'two_sec': 2,
        }

        lines = list(stdout_catcher.text.split('\n'))

        # make sure times fall int right slots
        for line in lines:
            if line:
                words = line.split()
                name = words[0]
                time = parse('T'.join(words[1:]))
                self.assertEqual(time.second % base_lookup[name], 0)

        # make sure the tasks were run the proper number of times
        counter = Counter()
        for line in lines:
            if line:
                counter.update({line.split()[0]: 1})

        self.assertEqual(counter['two_sec'], 3)
        self.assertEqual(counter['three_sec'], 2) 
開發者ID:robdmc,項目名稱:crontabs,代碼行數:34,代碼來源:test_all.py

示例9: _bump_up_time_by_microsecond

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def _bump_up_time_by_microsecond(time):
    """
    Helper function bumping up the given datetime.time by a microsecond,
    cycling around silently to 00:00:00.0 in case of an overflow.

    @param time: Time object.
    @type time: B{datetime}.I{time}
    @return: Time object.
    @rtype: B{datetime}.I{time}

    """
    dt = datetime.datetime(2000, 1, 1, time.hour, time.minute,
        time.second, time.microsecond)
    dt += datetime.timedelta(microseconds=1)
    return dt.time() 
開發者ID:suds-community,項目名稱:suds,代碼行數:17,代碼來源:date.py

示例10: _time_from_match

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def _time_from_match(match_object):
    """
    Create a time object from a regular expression match.

    Returns the time object and information whether the resulting time should
    be bumped up by one microsecond due to microsecond rounding.

    Subsecond information is rounded to microseconds due to a restriction in
    the python datetime.datetime/time implementation.

    The regular expression match is expected to be from _RE_DATETIME or
    _RE_TIME.

    @param match_object: The regular expression match.
    @type match_object: B{re}.I{MatchObject}
    @return: Time object + rounding flag.
    @rtype: tuple of B{datetime}.I{time} and bool

    """
    hour = int(match_object.group('hour'))
    minute = int(match_object.group('minute'))
    second = int(match_object.group('second'))
    subsecond = match_object.group('subsecond')

    round_up = False
    microsecond = 0
    if subsecond:
        round_up = len(subsecond) > 6 and int(subsecond[6]) >= 5
        subsecond = subsecond[:6]
        microsecond = int(subsecond + "0" * (6 - len(subsecond)))
    return datetime.time(hour, minute, second, microsecond), round_up 
開發者ID:suds-community,項目名稱:suds,代碼行數:33,代碼來源:date.py

示例11: today

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def today(timezone=None, format=None):
    """Returns today's date at midnight as a DADateTime object."""
    ensure_definition(timezone, format)
    if timezone is None:
        timezone = get_default_timezone()
    val = pytz.utc.localize(datetime.datetime.utcnow()).astimezone(pytz.timezone(timezone))
    if format is not None:
        return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)).format_date(format)
    else:
        return dd(val.replace(hour=0, minute=0, second=0, microsecond=0)) 
開發者ID:jhpyle,項目名稱:docassemble,代碼行數:12,代碼來源:util.py

示例12: replace_time

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def replace_time(self, time):
        return self.replace(hour=time.hour, minute=time.minute, second=time.second, microsecond=time.microsecond) 
開發者ID:jhpyle,項目名稱:docassemble,代碼行數:4,代碼來源:util.py

示例13: dd

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def dd(obj):
    if isinstance(obj, DADateTime):
        return obj
    return DADateTime(obj.year, month=obj.month, day=obj.day, hour=obj.hour, minute=obj.minute, second=obj.second, microsecond=obj.microsecond, tzinfo=obj.tzinfo) 
開發者ID:jhpyle,項目名稱:docassemble,代碼行數:6,代碼來源:util.py

示例14: dt

# 需要導入模塊: import time [as 別名]
# 或者: from time import second [as 別名]
def dt(obj):
    return datetime.datetime(obj.year, obj.month, obj.day, obj.hour, obj.minute, obj.second, obj.microsecond, obj.tzinfo) 
開發者ID:jhpyle,項目名稱:docassemble,代碼行數:4,代碼來源:util.py


注:本文中的time.second方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。