示例#1
0
def find_nearest_time(look_for, target_list):
    # 格式化查询数据
    look_for = time2secs(format_time(look_for))
    target_list = [
        time2secs(format_time(each_item)) for each_item in target_list
    ]
    return (secs2time(find_closest(look_for, target_list)))
示例#2
0
def find_nearest_time(look_for, target_data):
    what = time2secs(
        look_for
    )  # convert the time string you are looking for into its equivalent value in seconds
    where = [time2secs(t) for t in target_data
             ]  # convert the lines of time strings into seconds
    res = find_closest(what, where)  # supply's the converted data
    return (
        secs2time(res)
    )  # return the closest match to the calling code, after converting it back to a time string
示例#3
0
def find_nearest_time(look_for, target_data):
    #取两个参数,一个是时间字符串,以及一个时间字符列表
    what = time2secs(look_for)
    #将要查找的时间字符串转换为等价的秒数值
    where = [time2secs(t) for t in target_data]
    #将时间字符串行转换为秒数
    res = find_closest(what, where)
    #调用find_closest()并提供已转换的数据
    return (secs2time(res))


#转换后,将最接近的匹配结果返回给调用代码
def find_nearest_time(look_for, target_data):
    """
    查找的时间以及所搜索的时间列表,这个函数将把找到的最接近的时间作为一个字符串返回
    :param look_for:
    :param target_data:
    :return:
    """
    # 将要查找的时间字符串转换为等价的秒数值
    what = time2secs(look_for)
    print(what)
    # 将时间字符串行转换为秒数
    where = [time2secs(t) for t in target_data]
    print(where)
    # 查找最近的匹配的时间
    res = find_closest(what, where)
    # 返回时间字符串
    return secs2time(res)
def find_nearest_time(look_for, target_data):
    what = time2secs(look_for)
    where = [time2secs(t) for t in target_data]
    res = find_closest(what, where)
    return(secs2time(res))
示例#6
0
文件: last.py 项目: azych/python_head
def find_nearest_time(look_for, target_data):
	look_for = time2secs(look_for)
	target_data = [time2secs(t) for t in target_data]
	return(secs2time(find_closest(look_for, target_data)))
示例#7
0
def find_nearest_time(look_for, target_data):
	what = time2secs(look_for)					# convert the time string you are looking for into its equivalent value in seconds
	where = [time2secs(t) for t in target_data]	# convert the lines of time strings into seconds
	res = find_closest(what, where)				# supply's the converted data
	return(secs2time(res))						# return the closest match to the calling code, after converting it back to a time string
示例#8
0
def find_nearest_time(look_for, target_data):
    what = time2secs(look_for)
    where = [time2secs(t) for t in target_data]
    res = find_closest(what, where)
    return(secs2time(res))
示例#9
0
def find_nearest_time(look_for, target_data):
    look_for_value = time2secs(look_for)
    where_to_find = [time2secs(t) for t in target_data]
    target_value = find_closest(look_for_value, where_to_find)
    return secs2time(target_value)
def find_nearest_time(look_for, target_data):
    look_for = time2secs(look_for)
    data = [time2secs(each) for each in target_data]
    res = find_closest(look_for, data)
    return (secs2time(res))
示例#11
0
def find_nearest_time(look_for, target_data):
    what = time2secs(look_for)
    time = [time2secs(t) for t in target_data]
    ans = find_closest(what, time)
    return (secs2time(ans))