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


Python time.ctime方法代碼示例

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


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

示例1: load

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def load(self, dtype_out_time, dtype_out_vert=False, region=False,
             plot_units=False, mask_unphysical=False):
        """Load the data from the object if possible or from disk."""
        msg = ("Loading data from disk for object={0}, dtype_out_time={1}, "
               "dtype_out_vert={2}, and region="
               "{3}".format(self, dtype_out_time, dtype_out_vert, region))
        logging.info(msg + ' ({})'.format(ctime()))
        # Grab from the object if its there.
        try:
            data = self.data_out[dtype_out_time]
        except (AttributeError, KeyError):
            # Otherwise get from disk.  Try scratch first, then archive.
            try:
                data = self._load_from_disk(dtype_out_time, dtype_out_vert,
                                            region=region)
            except IOError:
                data = self._load_from_tar(dtype_out_time, dtype_out_vert)
        # Copy the array to self.data_out for ease of future access.
        self._update_data_out(data, dtype_out_time)
        # Apply desired plotting/cleanup methods.
        if mask_unphysical:
            data = self.var.mask_unphysical(data)
        if plot_units:
            data = self.var.to_plot_units(data, dtype_vert=dtype_out_vert)
        return data 
開發者ID:spencerahill,項目名稱:aospy,代碼行數:27,代碼來源:calc.py

示例2: step

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def step(self, amt=1):
        self.layout.all_off()

        a = "" + time.ctime()
        tIndex = [11, 12, 14, 15, 17, 18]
        colSize = [2, 4, 3, 4, 3, 4]

        for x in range(6):
            b = bin(128 + int(a[tIndex[x]]))
            for i in range(colSize[x]):
                is_off = b[6 + (4 - colSize[x]) + i] == '0'
                color = self.palette(int(is_off))
                self.layout.fillRect(
                    self._origX + (x) + (self._lightSize - 1) * x + self._colSpacing * x,
                    ((4 - colSize[x]) + i + self._origY) * self._lightSize,
                    self._lightSize, self._lightSize, color) 
開發者ID:ManiacalLabs,項目名稱:BiblioPixelAnimations,代碼行數:18,代碼來源:BinaryClock.py

示例3: info

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def info(log:str,target='console'):
    """
    log: text to record.
    target: 'console' to print log on screen or file to write in. 
    """
    if target=='console':
        thd=threading.Thread(target=print,args=(ctime(),':',log))
        thd.setDaemon(True)
        thd.start()
        thd.join()
    else:
        try:
            thd=threading.Thread(target=print,args=(ctime(),':',log))
            thd.setDaemon(True)
            thd.start()
            thd.join()
        except Exception as e:
            print(e) 
開發者ID:zhuoju36,項目名稱:StructEngPy,代碼行數:20,代碼來源:Logger.py

示例4: main

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def main():
    print('程序開始,當前時間', ctime())
    threads = []
    nloops = range(len(loops))

    for i in nloops:
        t = MyThread(loop, (i, loops[i]))
        threads.append(t)

    for i in nloops:
        threads[i].start()

    for i in nloops:
        threads[i].join()  # 等待進程完成

    print('程序結束,當前時間', ctime()) 
開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:18,代碼來源:3_thread_wayB.py

示例5: main

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def main():
    print('程序開始,當前時間', ctime())
    threads = []
    nloops = range(len(loops))

    for i in nloops:
        t = threading.Thread(target=loop, args=(i, loops[i]))
        threads.append(t)

    for i in nloops:
        threads[i].start()

    for i in nloops:
        threads[i].join() # 等待進程完成

    print('程序結束,當前時間', ctime()) 
開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:18,代碼來源:2_thread_wayA.py

示例6: main

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def main():
    nfuncs = range(len(funcs))
    print('*** 單線程')
    for i in nfuncs:
        print('starting', funcs[i].__name__, 'at:', ctime())
        print(funcs[i](n))
        print(funcs[i].__name__, 'finished at:', ctime())

    print('\n*** 多線程')
    threads = []
    for i in nfuncs:
        t = MyThread(funcs[i], (n,), funcs[i].__name__)
        threads.append(t)

    for i in nfuncs:
        threads[i].start()

    for i in nfuncs:
        threads[i].join()
        print(threads[i].getResult())
    print('ALL DONE') 
開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:23,代碼來源:4_thread_fac_fib.py

示例7: get_file_meta_data

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def get_file_meta_data(self, filepath, filename=None, getHash=False):
        """
        helper function to get meta information about a file to include it's path, date modified, size
        :param filepath: path to a file
        :param filename: filename
        :param getHash: whether or not the hash should be computed
        :return: a tuple of format (filename, filepath, filesize, filemodified, md5)
        """
        if filename is None:
            filename = os.path.split(filepath)[1]

        filemodified = time.ctime(os.path.getmtime(filepath))
        filesize = os.path.getsize(filepath)
        md5 = np.nan
        if getHash:
            md5 = self.get_file_hash(filepath)
        return (filename, filepath, filesize, filemodified, md5) 
開發者ID:egaus,項目名稱:MaliciousMacroBot,代碼行數:19,代碼來源:mmbot.py

示例8: save_grammar

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def save_grammar(self, filename=None):
        if not filename:
            ftypes = [('Chunk Gramamr', '.chunk'),
                      ('All files', '*')]
            filename = tkinter.filedialog.asksaveasfilename(filetypes=ftypes,
                                                      defaultextension='.chunk')
            if not filename: return
        if (self._history and self.normalized_grammar ==
            self.normalize_grammar(self._history[-1][0])):
            precision, recall, fscore = ['%.2f%%' % (100*v) for v in
                                         self._history[-1][1:]]
        elif self.chunker is None:
            precision = recall = fscore = 'Grammar not well formed'
        else:
            precision = recall = fscore = 'Not finished evaluation yet'

        with open(filename, 'w') as outfile:
            outfile.write(self.SAVE_GRAMMAR_TEMPLATE % dict(
                date=time.ctime(), devset=self.devset_name,
                precision=precision, recall=recall, fscore=fscore,
                grammar=self.grammar.strip())) 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:23,代碼來源:chunkparser_app.py

示例9: header_section

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def header_section(self):
        """Returns an ARFF header as a string."""
        # Header comment.
        s = ('% Weka ARFF file\n' +
             '% Generated automatically by NLTK\n' +
             '%% %s\n\n' % time.ctime())

        # Relation name
        s += '@RELATION rel\n\n'

        # Input attribute specifications
        for fname, ftype in self._features:
            s += '@ATTRIBUTE %-30r %s\n' % (fname, ftype)

        # Label attribute specification
        s += '@ATTRIBUTE %-30r {%s}\n' % ('-label-', ','.join(self._labels))

        return s 
開發者ID:rafasashi,項目名稱:razzy-spinner,代碼行數:20,代碼來源:weka.py

示例10: run

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def run( self ):
      """Vehicle waits unless/until light is green"""

      # stagger arrival times
      time.sleep( random.randrange( 1, 10 ) )

      # prints arrival time of car at intersection
      print "%s arrived at %s" % \
         ( self.getName(), time.ctime( time.time() ) )

      # wait for green light
      self.threadEvent.wait()

      # displays time that car departs intersection
      print "%s passes through intersection at %s" % \
         ( self.getName(), time.ctime( time.time() ) ) 
開發者ID:PythonClassRoom,項目名稱:PythonClassBook,代碼行數:18,代碼來源:fig19_15.py

示例11: generate

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def generate(compiled, codec):
    """Generate Rust source code from given compiled specification.

    """

    date = time.ctime()

    if codec == 'uper':
        helpers, types_code = uper.generate(compiled)
    else:
        raise Exception()

    source = SOURCE_FMT.format(version=__version__,
                               date=date,
                               helpers=helpers,
                               types_code=types_code)

    return source 
開發者ID:eerimoq,項目名稱:asn1tools,代碼行數:20,代碼來源:__init__.py

示例12: getwx

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def getwx():
    global wxurl
    global wxreply
    print "getting current and forecast:" + time.ctime()
    wxurl = 'https://api.darksky.net/forecast/' + \
        ApiKeys.dsapi + \
        '/'
    wxurl += str(Config.location.lat) + ',' + \
        str(Config.location.lng)
    wxurl += '?units=us&lang=' + Config.Language.lower()
    wxurl += '&r=' + str(random.random())
    print wxurl
    r = QUrl(wxurl)
    r = QNetworkRequest(r)
    wxreply = manager.get(r)
    wxreply.finished.connect(wxfinished) 
開發者ID:n0bel,項目名稱:PiClock,代碼行數:18,代碼來源:PyQtPiClock.py

示例13: run

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def run(self):
    while self.finish_time == 0:
      time.sleep(.25)
      global_step_val, = self.sess.run([self.global_step_op])
      if self.start_time == 0 and global_step_val >= self.start_at_global_step:
        # Use tf.logging.info instead of log_fn, since print (which is log_fn)
        # is not thread safe and may interleave the outputs from two parallel
        # calls to print, which can break tests.
        tf.logging.info('Starting real work at step %s at time %s' %
                        (global_step_val, time.ctime()))
        self.start_time = time.time()
        self.start_step = global_step_val
      if self.finish_time == 0 and global_step_val >= self.end_at_global_step:
        tf.logging.info('Finishing real work at step %s at time %s' %
                        (global_step_val, time.ctime()))
        self.finish_time = time.time()
        self.finish_step = global_step_val 
開發者ID:tensorflow,項目名稱:benchmarks,代碼行數:19,代碼來源:benchmark_cnn.py

示例14: __init__

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def __init__(self, output=None, **kwargs):
        super(XLSRenderer, self).__init__(**kwargs)

        # Make a single delegate text renderer for reuse. Most of the time we
        # will just replicate the output from the TextRenderer inside the
        # spreadsheet cell.
        self.delegate_text_renderer = text.TextRenderer(session=self.session)

        self.output = output or self.session.GetParameter("output")

        # If no output filename was give, just make a name based on the time
        # stamp.
        if self.output == None:
            self.output = "%s.xls" % time.ctime()

        try:
            self.wb = openpyxl.load_workbook(self.output)
            self.current_ws = self.wb.create_sheet()
        except IOError:
            self.wb = openpyxl.Workbook()
            self.current_ws = self.wb.active 
開發者ID:google,項目名稱:rekall,代碼行數:23,代碼來源:xls.py

示例15: crawl

# 需要導入模塊: import time [as 別名]
# 或者: from time import ctime [as 別名]
def crawl(url):
    """
    從給定的URL中提取出內容,並以列表的形式返回。
    """
    try:
        html = requests.get(url)
    except:
        with open("log.log","a") as file:
            file.write("Http error on " + time.ctime())
        time.sleep(60)
        return None
    soup = BeautifulSoup(html.text, 'lxml')
    data_list = []
    for cont in soup.find_all("div", {"class":"content"}):
        raw_data = cont.get_text()
        data = raw_data.replace("\n","")
        data_list.append(data)
    return data_list 
開發者ID:WiseDoge,項目名稱:crawler_examples,代碼行數:20,代碼來源:main.py


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