当前位置: 首页>>代码示例>>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;未经允许,请勿转载。