本文整理汇总了Python中time.split函数的典型用法代码示例。如果您正苦于以下问题:Python split函数的具体用法?Python split怎么用?Python split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了split函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: save_channels_rambler
def save_channels_rambler(date_invert, ADDRESS):
source = 1 #rambler
source_obj = TvForecastSources.objects.get(id = 1)
g.go(ADDRESS)
res = g.response.body
soup = BeautifulSoup(str(res))
for channel in soup.findAll("table", {"class":"grid-element"}):
must_del = True #для каждого нового канала
channel_my_id = rambler_to_mine_channel[channel.find('td', {"class" : "plain-event-logo"}).text]
channel_obj = TvChannels.objects.get(id = channel_my_id)
for param in channel.findAll("div", {"class":"plain-event"}):
#if channel_obj.id ==7 or channel_obj.id ==8 or channel_obj.id ==9: #временно только для первого канала
#print parmam.text
try:
name = param.find('a').text #название передачи
time = param.find('span').text #время показа
time_splitted = time.split(":")
except AttributeError:
name= param.contents[1].nextSibling # если не передача а сообщение все равно название передачи
time= param.find('span').text #время показа если не передача а сообщение
time_splitted = time.split(":")
#здесь можем сохранить объект в базу
tv_forecast_obj = TvForecast(source=source_obj,
channel = channel_obj,
#date = '2015-01-12', #из андреса
date = date_invert, #из андреса
time_hour = time_splitted[0],
time_minute= time_splitted[1],
name = name,
date_get = datetime.datetime.now().strftime("%Y-%m-%d") ,
)
#удалить записи по данному каналу на данную дату
if tv_forecast_obj:
if must_del ==True:
tv_forecast_obj_must_del = TvForecast.objects.filter(source = source_obj, date=date_invert, channel = channel_obj)
#print channel_obj.id
if tv_forecast_obj_must_del.count() != 0:
for tmd in tv_forecast_obj_must_del:
#print tmd.id
tmd.delete()
must_del = False
#tv_forecast_obj_must_del.delete()
tv_forecast_obj.save()
开发者ID:varikgit,项目名称:globalhome_ats,代码行数:49,代码来源:tv_forecast.py
示例17: ConvertTimeToMinutes
def ConvertTimeToMinutes(time):
"""Converts time in HH:MM:SS format to minutes."""
t = time.split('.')
if len(t) == 2:
time, fraction = time.split('.')
t = [int(x) for x in time.split(':')]
if len(t) == 2:
h = 0
m, s = t
else:
h, m, s = t
mins = h * 60 + m + s / 60.0
return mins
开发者ID:41734785,项目名称:thinkstats,代码行数:15,代码来源:race_predictor.py
示例18: convert_time
def convert_time(self, time):
"""
Helper function to convert the displaytime strings to
an actual integer minute represenation.
Examples: 'Nu' => 0, '8 min.'' => 8,
'12:22' (at the time of 12:18) => 4
'9' => 9
"""
if 'min' in time:
time = time.replace('min', '').replace('.', '').strip()
elif 'Nu' in time:
time = 0
elif ':' in time:
now = self.get_now()
# floor below minute
now = datetime.datetime(year=now.year, month=now.month, day=now.day,
hour=now.hour, minute=now.minute, second=0,
microsecond=0)
hour, minute = time.split(':')
dtime = datetime.datetime(year=now.year, month=now.month, day=now.day,
hour=int(hour), minute=int(minute), second=0,
microsecond=0)
# 00.00 wraparound?
if dtime < now:
dtime = dtime + datetime.timedelta(days=1)
time = round((dtime - now).total_seconds() / 60.0)
return int(time)
开发者ID:klec00,项目名称:publicTransportation,代码行数:29,代码来源:trafiklab.py
示例19: store_index_h5
def store_index_h5(self, time, index,flag = 1) :
"""Store information about:
* Time-stamp
* Total intensity
* Beam center
* Estimated Particle Size
* Estimated particle nr
"""
self.tot_t[index] = time.split('_')[1]
self.tot_int[index] = float(self.img.sum())
self.tot_peak1_int[index] = self.peak1
self.tot_peak2_int[index] = self.peak2
self.tot_streak_m[index] = self.streak_m
self.tot_streak_s[index] = self.streak_s
self.tot_cx[index] = self.cent[0]
self.tot_cy[index] = self.cent[1]
self.tot_size[index] = self.radius
self.tot_score[index] = self.score
if flag :
self.ave += self.img
开发者ID:cctbx,项目名称:cctbx-playground,代码行数:25,代码来源:fxs.py
示例20: as_dict
def as_dict(self):
self.photo = None
if self.picture:
self.photo = "/img?img_id=%s" % self.key()
self.created = self.created + datetime.timedelta(hours = 8)
self.lastModified = self.lastModified + datetime.timedelta(hours = 8)
date, time = self.lastSeen.split(" ")
year, month, day = map(int, date.split("-"))
hour, minute, second = map(int, time.split(":"))
self.lastSeenTime = datetime.datetime(year, month, day, hour, minute, second)
d = {'name': self.name,
'age': self.age,
'last_seen': self.lastSeenAt,
'last_seen_date': self.lastSeenTime.strftime("%d %b %Y"),
'last_seen_time': self.lastSeenTime.strftime("%I:%M %p"),
'contact_details': self.contactDetails,
'user': self.user,
'found': self.found,
'posted_date': self.created.strftime("%b %d, %Y"),
'posted_time': self.created.strftime("%I:%M %p")
}
if self.photo:
d['picture'] = self.photo
if self.additionalDetails:
d['additional_details'] = self.additionalDetails
if not (self.created.strftime("%I:%M %p") ==
self.lastModified.strftime("%I:%M %p") and
(self.created.strftime("%b %d, %Y") ==
self.lastModified.strftime("%b %d, %Y"))):
d['last_modified_date'] = self.lastModified.strftime("%b %d, %Y")
d['last_modified_time'] = self.lastModified.strftime("%I:%M %p")
return d
开发者ID:denzelchung,项目名称:TP-Major-Project,代码行数:34,代码来源:database.py
注:本文中的time.split函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论