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


Python time.split函数代码示例

本文整理汇总了Python中time.split函数的典型用法代码示例。如果您正苦于以下问题:Python split函数的具体用法?Python split怎么用?Python split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: fetchServer2Data_Live

def fetchServer2Data_Live():
    #called every minute
    data = urllib2.urlopen("https://api.bitcoinaverage.com/history/USD/per_minute_24h_sliding_window.csv")
    PriceWindow = []
    firstLine = True
    for line in data:
        if firstLine:
            firstLine = False
            continue
        time = line.split(",")[0]
        time1 = time.split(" ")[0]
        time2 = time.split(" ")[1]
        time = time1+"-"+time2
        # get rid of second
        time1 = time.split(":")[0]
        time2 = time.split(":")[1]
        time = time1+":"+time2
        time = UTCtoLinux(time)
        price = float(line.split(",")[1])
        Price[time] = price
        PriceWindow.append(price)

    # updating the internal data structure
    # now time points to the latest time
    print "Adding Server2 data at:" + linuxToUTC(time) + " Price " + str(price)
    calculateTradingStrategies(PriceWindow,time)
开发者ID:PercyARS,项目名称:OTPP_Project,代码行数:26,代码来源:server.py

示例2: get_bookmarks_time

def get_bookmarks_time(url, opener=opener):
    # go to the bookmarks page of the work and find the timestamps for the bookmarks
    # returns a dict of {month:# of bookmarks in the month}

    req = urllib2.Request(url)
    page = bs(opener.open(req))
    page_list = [i for i in re.findall('<a href="(.*?)>', str(page)) if "bookmarks?" in i]
    page_list = sorted(list(set([i.split()[0].replace('"', "") for i in page_list])))

    dt = re.findall('<p class="datetime">(.*?)</p>', str(page))
    times = []
    month_dict = {
        "Jan": "01",
        "Feb": "02",
        "Mar": "03",
        "Apr": "04",
        "May": "05",
        "Jun": "06",
        "Jul": "07",
        "Aug": "08",
        "Sep": "09",
        "Oct": "10",
        "Nov": "11",
        "Dec": "12",
    }
    for time in dt:
        times.append(time.split()[2] + "-" + month_dict.get(time.split()[1]))
    times = times[1:]
    if page_list != []:
        for page in page_list:
            times += get_bookmarks_time_subpages("http://archiveofourown.org" + page, opener=opener)
    c = Counter(times)
    return {time: c[time] for time in times}
开发者ID:yzjing,项目名称:ao3,代码行数:33,代码来源:scraper_2001_2100.py

示例3: handleRecentsMessage

    def handleRecentsMessage(self, recents):
        if not recents and syncthing_repositories:
            return

        recents = [recent for recent in recents if recent['type'] == 'LocalIndexUpdated']
        recents = recents[-10:]
        folders = {repo['ID']: repo['Directory'] for repo in syncthing_repositories}

        if recents:
            # remove all actions in recents menu
            self.recents.clear()
            max_length = max([len(recent['data']['name']) for recent in recents])

        for recent in recents:
            filename = recent['data']['name']
            directory = recent['data']['repo']
            time = recent['time']
            time = '+'.join([time.split('+')[0][:-1], time.split('+')[1]]) # hack to let arrow parse it
            time = arrow.get(time).humanize()

            action = QAction('%-*s (%s)' % (-max_length, filename, time), self.recents)

            if os.path.exists(os.path.join(folders[directory], filename)):
                action.setIcon(QIcon('icons/newfile.png'))
                action.triggered.connect(lambda: self.open_dir(folders[directory]))
            else:
                action.setIcon(QIcon('icons/delfile.png'))
                folder = os.path.join(folders[directory], '.stversions')

                if os.path.exists(os.path.join(folder, filename)):
                    action.triggered.connect(lambda: self.open_dir(folder))

            self.recents.addAction(action)
开发者ID:Astalaseven,项目名称:syncthing-gui,代码行数:33,代码来源:sync.py

示例4: get_song_length

def get_song_length(duration, songnumber):
    duration = str(duration)
    songnumber = int(songnumber)
    if songnumber <= 1:
        time = duration.split(" ")[0]
        minutes_ev = time.split(":")[0]
        seconds_ev = time.split(":")[1]
        minutes = "".join([letter for letter in minutes_ev if letter.isdigit()])
        seconds = "".join([letter for letter in seconds_ev if letter.isdigit()])
        songtime = (int(minutes) * 60) + int(seconds)
        return songtime

    else:
        songfetch = int(songnumber) - 1
        if len(duration.split(" ")) >= songfetch:
            time = duration.split(" ")[songfetch]
            minutes_ev = time.split(":")[0]
            seconds_ev = time.split(":")[1]
            minutes = "".join([letter for letter in minutes_ev if letter.isdigit()])
            seconds = "".join([letter for letter in seconds_ev if letter.isdigit()])
            songtime = (int(minutes) * 60) + int(seconds)
            return songtime

        else:
            global __settings__
            int(getsl(__settings__.getSetting("sl_custom")))
            return int(getsl(__settings__.getSetting("sl_custom")))
开发者ID:Alwnikrotikz,项目名称:insayne-projects,代码行数:27,代码来源:common.py

示例5: time_to_int

def time_to_int(time):
    if time.count(":") == 2:
        (hour, min, sec) = time.split(":")
        return (int(hour) * 3600) + (int(min) * 60) + int(sec) 
    else:
        (min, sec) = time.split(":")
        return (int(min) * 60) + int(sec)
开发者ID:ZachGoldberg,项目名称:Pandora-UPnP,代码行数:7,代码来源:server.py

示例6: toDateTime

def toDateTime(sVal, iDefault=None):
    """ Suponer formato Iso OrderingDate 
    """
    if sVal is None:
        return iDefault
    try:
        if sVal.count("T") > 0:
            # IsoFormat DateTime
            (date, time) = sVal.split("T")
            (an, mois, jour) = date.split('-')
            (h, m, s) = time.split(':')
            return datetime.datetime(int(an), int(mois), int(jour), int(h), int(m), int(s))

        elif sVal.count("-") == 2:
            # IsoFormat Date
            (an, mois, jour) = sVal.split('-')
            return datetime.date(int(an), int(mois), int(jour))

        elif sVal.count("/") == 2:
            if sVal.count(' ') > 0:
                (date, time) = sVal.split(" ")
                (jour, mois, an) = date.split('/')
                (h, m, s) = time.split(':')
                return datetime.datetime(int(an), int(mois), int(jour), int(h), int(m), int(s))
            else:
                (jour, mois, an) = date.split('/')
                return datetime.date(int(an), int(mois), int(jour))
    except:
        return iDefault
开发者ID:DarioGT,项目名称:django-softmachine,代码行数:29,代码来源:utilsConvert.py

示例7: _srtTc2ms

 def _srtTc2ms(self, time):
     if ',' in time:
         split_time = time.split(',')
     else:
         split_time = time.split('.')
     minor = split_time[1]
     major = split_time[0].split(':')
     return (int(major[0])*3600 + int(major[1])*60 + int(major[2])) * 1000 + int(minor)
开发者ID:a4tech,项目名称:iptvplayer-for-e2,代码行数:8,代码来源:iptvsubtitles.py

示例8: run

    def run(self):
        """ Gets tracking information from the APRS receiver """

        aprsSer = self.APRS.getDevice()

        while(not self.aprsInterrupt):
            ### Read the APRS serial port, and parse the string appropriately                               ###
            # Format:
            # "Callsign">CQ,WIDE1-1,WIDE2-2:!"Lat"N/"Lon"EO000/000/A="Alt"RadBug,23C,982mb,001
            # ###
            try:
                line = str(aprsSer.readline())
                print(line)
                idx = line.find(self.callsign)
                if(idx != -1):
                    line = line[idx:]
                    line = line[line.find("!") + 1:line.find("RadBug")]
                    line = line.split("/")

                    # Get the individual values from the newly created list ###
                    time = datetime.utcfromtimestamp(
                        time.time()).strftime('%H:%M:%S')
                    lat = line[0][0:-1]
                    latDeg = float(lat[0:2])
                    latMin = float(lat[2:])
                    lon = line[1][0:line[1].find("W")]
                    lonDeg = float(lon[0:3])
                    lonMin = float(lon[3:])
                    lat = latDeg + (latMin / 60)
                    lon = -lonDeg - (lonMin / 60)
                    alt = float(line[3][2:])
                    aprsSeconds = float(time.split(
                        ':')[0]) * 3600 + float(time.split(':')[1]) * 60 + float(time.split(':')[2])

                    ### Create a new location object ###
                    try:
                        newLocation = BalloonUpdate(
                            time, aprsSeconds, lat, lon, alt, "APRS", self.mainWindow.groundLat, self.mainWindow.groundLon, self.mainWindow.groundAlt)
                    except:
                        print(
                            "Error creating a new balloon location object from APRS Data")

                    try:
                        # Notify the main GUI of the new location
                        self.aprsNewLocation.emit(newLocation)
                    except Exception, e:
                        print(str(e))
            except:
                print("Error retrieving APRS Data")

        ### Clean Up ###
        try:
            aprsSer.close()         # Close the APRS Serial Port
        except:
            print("Error closing APRS serial port")

        self.aprsInterrupt = False
开发者ID:MSU-BOREALIS,项目名称:Antenna_Tracker,代码行数:57,代码来源:GetData.py

示例9: get_bookmarks_time_subpages

def get_bookmarks_time_subpages(url, opener=opener):
    #A work's bookmarks can take up multiple pages. In this case, all timestamp information is add to the first page.
    req = urllib2.Request(url)
    page = bs(opener.open(req))
    dt = re.findall('<p class="datetime">(.*?)</p>', str(page))
    times = []
    month_dict = {'Jan':'01', 'Feb':'02','Mar':'03', 'Apr':'04', 'May':'05', 'Jun':'06', 'Jul':'07', 'Aug':'08', 'Sep':'09', 'Oct':'10', 'Nov':'11', 'Dec':'12'}
    for time in dt:
        times.append(time.split()[2] + '-' + month_dict.get(time.split()[1]))
    return times[1:]
开发者ID:yzjing,项目名称:ao3,代码行数:10,代码来源:scraper_3701_3800.py

示例10: get_bookmarks_time_subpages

def get_bookmarks_time_subpages(url, opener=opener):
    req = urllib2.Request(url)
    page = bs(opener.open(req))
    dt = re.findall('<p class="datetime">(.*?)</p>', str(page))
    times = []
    month_dict = {'Jan':'01', 'Feb':'02','Mar':'03', 'Apr':'04', 'May':'05', 'Jun':'06', 'Jul':'07', 'Aug':'08', 'Sep':'09', 'Oct':'10', 'Nov':'11', 'Dec':'12'}
    for time in dt:
        times.append(time.split()[2] + '-' + month_dict.get(time.split()[1]))
    times = times[1:]
    return times
开发者ID:yzjing,项目名称:ao3,代码行数:10,代码来源:20160313_crawler.py

示例11: time_convert

	def time_convert(self, time):
		print "[YWeather] Time convert"
		tmp_time = ''
		if time.endswith('pm'):
			tmp_time = '%s:%s' % (int(time.split()[0].split(':')[0]) + 12, time.split()[0].split(':')[-1])
		else:
			tmp_time = time.replace('am', '').strip()
		if len(tmp_time) is 4:
			return '0%s' % tmp_time
		else:
			return tmp_time
开发者ID:TomTelos,项目名称:YWeather,代码行数:11,代码来源:plugin.py

示例12: get_timedelta

def get_timedelta(time):
    minutes = 0
    if len(time.split(':')) > 1:
        minutes, seconds = [float(t) for t in time.split(':')]
    else:
        try:
            seconds = float(time)
        except ValueError:
            seconds = 1000 * 1000
        
    return datetime.timedelta(minutes=minutes, seconds=seconds)
开发者ID:malcolmjmr,项目名称:track,代码行数:11,代码来源:direct_athletics.py

示例13: timeshifter

def timeshifter(time):

    #06/02/2014 02:30 -> 2014-06-02T02:30

    try:
        origdate, origtime = time.split(' ')[0], time.split(' ')[1]

        date = origdate.split('/')[2] + '-' + origdate.split('/')[0] + '-' + origdate.split('/')[1]
        time = origtime + ':00'

        return date + 'T' + time
    except Exception,e :
        return None
开发者ID:dangpu,项目名称:momoko,代码行数:13,代码来源:feiquanqiuRoundParser.py

示例14: convertTime

def convertTime(time):
    timeInSeconds = 0
    if time.find(":")>0:
        min,sec = time.split(":")
    elif time.find("m")>0:
         min,sec = time.split("m")
         sec = sec.replace("s","")
    else:
        min = 0
        sec = 0
    min = int(min)
    sec = int(sec)       
    return (min*60)+sec
开发者ID:bonethrown,项目名称:Machine-learning-toolkit-,代码行数:13,代码来源:utils.py

示例15: generatebeginTimecode

 def generatebeginTimecode(begin_time_list):
     beginTimecode_list=list()
     for i in range(0, len(begin_time_list)):
         datetime = begin_time_list[i].split(' ')[0]
         time = begin_time_list[i].split(' ')[1]
         year = int(datetime.split('-')[0])
         month = int(datetime.split('-')[1])
         day = int(datetime.split('-')[2])
         hour = int(time.split(':')[0])
         minute = int(time.split(':')[1]) 
         second ='00'
         beginTimecode = str(year)+str('%02d'%month)+str('%02d'%day)+str('%02d'%hour)+str('%02d'%minute)+second
         beginTimecode_list.append(beginTimecode)
     return beginTimecode_list
开发者ID:dafoyiming,项目名称:DDishEPG,代码行数:14,代码来源:DDishEPG.py


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