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


Python time.split方法代碼示例

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


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

示例1: parse_qs

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
    """
    Like C{cgi.parse_qs}, but with support for parsing byte strings on Python 3.

    @type qs: C{bytes}
    """
    d = {}
    items = [s2 for s1 in qs.split(b"&") for s2 in s1.split(b";")]
    for item in items:
        try:
            k, v = item.split(b"=", 1)
        except ValueError:
            if strict_parsing:
                raise
            continue
        if v or keep_blank_values:
            k = unquote(k.replace(b"+", b" "))
            v = unquote(v.replace(b"+", b" "))
            if k in d:
                d[k].append(v)
            else:
                d[k] = [v]
    return d 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:25,代碼來源:http.py

示例2: fromChunk

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def fromChunk(data):
    """
    Convert chunk to string.

    @type data: C{bytes}

    @return: tuple of (result, remaining) - both C{bytes}.

    @raise ValueError: If the given data is not a correctly formatted chunked
        byte string.
    """
    prefix, rest = data.split(b'\r\n', 1)
    length = int(prefix, 16)
    if length < 0:
        raise ValueError("Chunk length must be >= 0, not %d" % (length,))
    if rest[length:length + 2] != b'\r\n':
        raise ValueError("chunk must end with CRLF")
    return rest[:length], rest[length + 2:] 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:20,代碼來源:http.py

示例3: parseContentRange

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def parseContentRange(header):
    """
    Parse a content-range header into (start, end, realLength).

    realLength might be None if real length is not known ('*').
    """
    kind, other = header.strip().split()
    if kind.lower() != "bytes":
        raise ValueError("a range of type %r is not supported")
    startend, realLength = other.split("/")
    start, end = map(int, startend.split("-"))
    if realLength == "*":
        realLength = None
    else:
        realLength = int(realLength)
    return (start, end, realLength) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:http.py

示例4: parseCookies

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def parseCookies(self):
        """
        Parse cookie headers.

        This method is not intended for users.
        """
        cookieheaders = self.requestHeaders.getRawHeaders(b"cookie")

        if cookieheaders is None:
            return

        for cookietxt in cookieheaders:
            if cookietxt:
                for cook in cookietxt.split(b';'):
                    cook = cook.lstrip()
                    try:
                        k, v = cook.split(b'=', 1)
                        self.received_cookies[k] = v
                    except ValueError:
                        pass 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:22,代碼來源:http.py

示例5: getRequestHostname

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def getRequestHostname(self):
        """
        Get the hostname that the user passed in to the request.

        This will either use the Host: header (if it is available) or the
        host we are listening on if the header is unavailable.

        @returns: the requested hostname
        @rtype: C{bytes}
        """
        # XXX This method probably has no unit tests.  I changed it a ton and
        # nothing failed.
        host = self.getHeader(b'host')
        if host:
            return host.split(b':', 1)[0]
        return networkString(self.getHost().host) 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:18,代碼來源:http.py

示例6: _authorize

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def _authorize(self):
        # Authorization, (mostly) per the RFC
        try:
            authh = self.getHeader(b"Authorization")
            if not authh:
                self.user = self.password = ''
                return
            bas, upw = authh.split()
            if bas.lower() != b"basic":
                raise ValueError()
            upw = base64.decodestring(upw)
            self.user, self.password = upw.split(b':', 1)
        except (binascii.Error, ValueError):
            self.user = self.password = ""
        except:
            log.err()
            self.user = self.password = "" 
開發者ID:proxysh,項目名稱:Safejumper-for-Desktop,代碼行數:19,代碼來源:http.py

示例7: _authorize

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def _authorize(self):
        # Authorization, (mostly) per the RFC
        try:
            authh = self.getHeader(b"Authorization")
            if not authh:
                self.user = self.password = ''
                return
            bas, upw = authh.split()
            if bas.lower() != b"basic":
                raise ValueError()
            upw = base64.decodestring(upw)
            self.user, self.password = upw.split(b':', 1)
        except (binascii.Error, ValueError):
            self.user = self.password = ""
        except:
            self._log.failure('')
            self.user = self.password = "" 
開發者ID:wistbean,項目名稱:learn_python3_spider,代碼行數:19,代碼來源:http.py

示例8: extract_consume_per_person

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def extract_consume_per_person(file_name, consume_dict):
    lines = open(file_name).readlines()
    for line in lines:
        temps = line.strip("\r\n").split("$")
        id = temps[0]
        totol_amount = 0
        active_date_set = set()

        for i in range(1, len(temps)):
            records = temps[i].split(",")
            cate = records[0].strip("\"")
            amount = float(records[4].strip("\""))
            time = records[3].strip("\"")
            date = time.split(" ")[0]
            active_date_set.add(date)
            if cate == "POS消費":
                totol_amount += amount
        consume_dict[id] = float(totol_amount) / len(active_date_set) 
開發者ID:lzddzh,項目名稱:DataMiningCompetitionFirstPrize,代碼行數:20,代碼來源:consume_rank_feature.py

示例9: extract_rank_feature

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def extract_rank_feature(file_name, final_rank, score_dict, if_train):
    if if_train:
        w = open("../original_data/rank_feature_train.txt", 'w')
    else:
        w = open("../original_data/rank_feature_test.txt", 'w')

    lines = open(file_name).readlines()
    for line in lines:
        if if_train:
            id = line.strip().split(",")[0]
        else:
            id = line.strip()
            print id
        w.write("{")
        w.write('"stuId": ' + id + ", ")

        if score_dict.has_key(id) and final_rank.has_key(id):
            w.write('"rank_in_faculty":' + str(final_rank[id]) + "," + '"rank_score_consume":' + str(
                final_rank[id] * score_dict[id]) + "} \n")
        else:
            w.write(
                '"rank_in_faculty":' + str(final_rank.get(id, -999)) + "," + '"rank_score_consume":' + str(
                    -999) + "} \n")

    w.close() 
開發者ID:lzddzh,項目名稱:DataMiningCompetitionFirstPrize,代碼行數:27,代碼來源:consume_rank_feature.py

示例10: getImagesAndLabels

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def getImagesAndLabels(path):
    imagePaths = [os.path.join(path, f) for f in os.listdir(path)]
    # create empth face list
    faceSamples = []
    # create empty ID list
    Ids = []
    # now looping through all the image paths and loading the Ids and the images
    for imagePath in imagePaths:
        # loading the image and converting it to gray scale
        pilImage = Image.open(imagePath).convert('L')
        # Now we are converting the PIL image into numpy array
        imageNp = np.array(pilImage, 'uint8')
        # getting the Id from the image

        Id = int(os.path.split(imagePath)[-1].split(".")[1])
        # extract the face from the training image sample
        faces = detector.detectMultiScale(imageNp)
        # If a face is there then append that in the list as well as Id of it
        for (x, y, w, h) in faces:
            faceSamples.append(imageNp[y:y + h, x:x + w])
            Ids.append(Id)
    return faceSamples, Ids 
開發者ID:Spidy20,項目名稱:Attendace_management_system,代碼行數:24,代碼來源:AMS_Run.py

示例11: get_app_pid

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def get_app_pid(self, packageName):
        """
        獲取進程pid
        args:
        - packageName -: 應用包名
        usage: getPid("com.android.settings")
        """
        if self.system is "Windows":
            pidinfo = self.shell("ps | findstr %s$" % packageName).stdout.read()
        else:
            pidinfo = self.shell("ps | grep -w %s" % packageName).stdout.read()

        if pidinfo == '':
            return "the process doesn't exist."

        pattern = re.compile(r"\d+")
        result = pidinfo.split(" ")
        result.remove(result[0])

        return  pattern.findall(" ".join(result))[0] 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:22,代碼來源:AdbCommand.py

示例12: get_battery_status

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def get_battery_status(self):
        """
        獲取電池充電狀態
        BATTERY_STATUS_UNKNOWN:未知狀態
        BATTERY_STATUS_CHARGING: 充電狀態
        BATTERY_STATUS_DISCHARGING: 放電狀態
        BATTERY_STATUS_NOT_CHARGING:未充電
        BATTERY_STATUS_FULL: 充電已滿
        """
        statusDict = {1 : "BATTERY_STATUS_UNKNOWN",
                      2 : "BATTERY_STATUS_CHARGING",
                      3 : "BATTERY_STATUS_DISCHARGING",
                      4 : "BATTERY_STATUS_NOT_CHARGING",
                      5 : "BATTERY_STATUS_FULL"}
        status = self.shell("dumpsys battery | %s status" %self.find_type).stdout.read().split(": ")[-1]

        return statusDict[int(status)] 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:19,代碼來源:AdbCommand.py

示例13: do_send_text

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def do_send_text(self, string):
        """
        發送一段文本,隻能包含英文字符和空格,多個空格視為一個空格
        usage: sendText("i am unique")
        """
        text = str(string).split(" ")
        out = []
        for i in text:
            if i != "":
                out.append(i)
        length = len(out)
        for i in xrange(length):
            self.shell("input text %s" % out[i])
            if i != length - 1:
                self.sendKeyEvent(EventKeys.SPACE)
        time.sleep(0.5) 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:18,代碼來源:AdbCommand.py

示例14: do_stop_and_restart_5037

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def do_stop_and_restart_5037(self):
        pid1 = os.popen("netstat -ano | findstr 5037 | findstr  LISTENING").read()
        if pid1 is not None:
            pid = pid1.split()[-1]
        # 下麵的命令執行結果,可能因電腦而異,若獲取adb.exe時出錯,可自行調試!
        # E:\>tasklist /FI "PID eq 10200"
        # Image Name                     PID Session Name        Session#    Mem Usage
        # ========================= ======== ================ =========== ============
        # adb.exe                      10200 Console                    1      6,152 K

        process_name = os.popen('tasklist /FI "PID eq %s"' %pid).read().split()[-6]
        process_path = os.popen('wmic process where name="%s" get executablepath' %process_name).read().split("\r\n")[1]

        # #分割路徑,得到進程所在文件夾名
        # name_list = process_path.split("\\")
        # del name_list[-1]
        # directory = "\\".join(name_list)
        # #打開進程所在文件夾
        # os.system("explorer.exe %s" %directory)
        # 殺死該進程
        os.system("taskkill /F /PID %s" %pid)
        os.system("adb start-server") 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:24,代碼來源:AdbCommand.py

示例15: get_crash_log

# 需要導入模塊: import time [as 別名]
# 或者: from time import split [as 別名]
def get_crash_log(self):
        # 獲取app發生crash的時間列表
        time_list = []
        result_list = self.shell("dumpsys dropbox | findstr data_app_crash").stdout.readlines()
        for time in result_list:
            temp_list = time.split(" ")
            temp_time= []
            temp_time.append(temp_list[0])
            temp_time.append(temp_list[1])
            time_list.append(" ".join(temp_time))

        if time_list is None or len(time_list) <= 0:
            print ">>>No crash log to get"
            return None
        log_file = "T://Exception_log_%s.txt" % self.timestamp()
        f = open(log_file, "wb")
        for timel in time_list:
            cash_log = self.shell(timel).stdout.read()
            f.write(cash_log)
        f.close()
        print ">>>check local file" 
開發者ID:gitjayzhen,項目名稱:AppiumTestProject,代碼行數:23,代碼來源:AdbCommand.py


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