精华内容
下载资源
问答
  • ctime
    千次阅读
    2020-02-11 22:02:55

    目录

    1、时间处理函数

    2、函数

    3、测试


    1、时间处理函数

    头文件<time.h>;<ctime>。

    2、函数

    clock_t t;         CPU流逝时间的类型
    time_t t;          获取当前系统时间
    struct tm *ptm;    日历格式时间
    clock();           返回CPU流逝的时间,1/CLOCKS_PER_SEC(CPU运行一次的时间) 
    time(0);           返回当前系统时间
    difftime();        获取两个time_t之间的差额,是double值,单位秒
    localtime();       将time_t转为struct tm,考虑时区
    gmtime();          将time_t转为struct tm,不考虑时区
    asctime(ptm);      将struct tm转为标准日历时间字符串
    strftime();        将struct tm转为用户自定义的日历字符串
    ctime();           将struct tm转为标准日历时间字符串 并考虑时区
    mktime(ptm);       将struct tm转为time_t

    3、测试

    #include <iostream>
    #include <chrono>
    #include <ctime>
    #include <string>
    
    #pragma warning(disable:4996)
    
    using namespace std;
    
    int main()
    {
    	//CPU流逝的时间。 1/CLOCKS_PER_SEC(CPU运行一次的时间) 
    	clock_t t = clock();
    
    	//获取当前时间
    	time_t time1 = time(0);
    
    	//将time_t转为struct tm,考虑时区
    	struct tm *ptm = localtime(&time1);
    
    	//将time_t转为struct tm,不考虑时区
    	ptm = gmtime(&time1);
    
    	//将struct tm转为标准日历时间字符串
    	cout << asctime(ptm) << endl;
    
    	//将struct tm转为标准日历时间字符串 并考虑时区
    	cout << ctime(&time1) << endl;
    
    	//将struct tm转为time_t
    	time1 = mktime(ptm);
    	system("pause");
    }

     

    更多相关内容
  • ctime()方法转换,因为历元到表示本地时间的字符串表示以秒为单位的时间。如果不设置秒时或None,所返回的时间的当前time()被使用。使用asctime(localtime(secs))。不使用ctime()的区域信息。 语法 以下是ctime()...
  • linux下的find命令提供了相当多的查找条件,功能很强大,由于find的功能很强大,所以他的选项也很多,今天我们来细说一下find命令下的三个时间参数atime,ctime,mtime. atime:access time,最近一次访问时间,当使用...
  • 定义一个时间类CTime,c。输入一个起始时间和一个结束时间(起始时间早于结束时间),通过运算符重载-(减号),计算这两个时间相隔多少秒钟。说明:这两个时间在同一小时之内,且采用60分钟60秒钟的计时分式,即从00:...
  • 次 用法 #golang的文件时间 Go在大多数平台上都具有隐藏的时间功能,此存储库使它们易于访问。 package main import ( "log" ...) func main () { t , err := times .... log .... log .... log .... if t ....
  • 怎样将CString转换成CTime类型
  • super_CTime CTime的各种转换子程序库。和字符串的转换、和数字的转换等等 std::string getDateString(bool fgf);//获得表示当前日期的字符串,fgf表示是否需要分隔符 std::string getTimeString(bool fgf);//...
  • 如何将CTime 类型转换为CString
  • VS2019 CTime、CTimeSpan例程
  • UxTClib ESP8266 / ESP32的时钟库 为不同RTC IC上的读取/更新时间提供简单/向下的RTC类。 Arduino框架 核心/ HAL ESP8266 / ESP32和C / C ++时间库 精简RTC库
  • CTime

    2008-03-22 12:43:44
    CTime:VC++编写定时器的程序,功能:一个在edit中显示为当前时间,另外两个显示为定时器的功能
  • Linux系统ctimemtime和atime命令详解linux操作系统 电脑资料 在linux中对于文件有ctimemtime和atime三种时间一种是访问时间一种是修改时间另一种是改变文件时间了下面一起来看看吧 atimeAess Time 最后一次访问文件...
  • ctimectime函数)

    2021-03-22 08:59:33
    ctime(ctime函数)在头文件中定义​​char * ctime(const time_t * time);(1)​errno_t ctime_s(char * buffer,rsize_t bufsz,const time_t * time);(2)(自C11以来)1)将时间以来的给定时间转换为当地日历,然后转换...

    ctime(ctime函数)

    在头文件中定义

    char * ctime(const time_t * time);

    (1)

    errno_t ctime_s(char * buffer,rsize_t bufsz,const time_t * time);

    (2)

    (自C11以来)

    1)将时间以来的给定时间转换为当地日历,然后转换为文本表示,就像通过调用一样asctime(localtime(time))。

    2)与(1)相同,只是该函数等同于asctime_s(buffer, bufsz, localtime_s(time, &(struct tm){0})),并且在运行时检测到以下错误并调用当前安装的约束处理程序函数:

    buffer或者time是空指针

    bufsz小于26或大于RSIZE_MAX

    与所有边界检查的函数一样,ctime_s只有__STDC_LIB_EXT1__在实现定义并且用户在包含之前定义__STDC_WANT_LIB_EXT1__为整数常量时1才能保证可用time.h。

    结果字符串具有以下格式:

    Www Mmm dd hh:mm:ss yyyy\n

    Www-一周的一天(之一Mon,Tue,Wed,Thu,Fri,Sat,Sun)。

    Mmm-月(一Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)。

    dd - 每月的一天

    hh - 小时

    mm - 分钟

    ss - 秒

    yyyy - 年

    该功能不支持本地化。

    参数

    时间

    -

    指向指定打印时间的time_t对象的指针

    缓冲

    -

    指向大小至少为bufsz的char数组元素的指针

    bufsz

    -

    最大输出字节数,通常是缓冲区指向的缓冲区的大小

    返回值

    1)指向保存日期和时间文本表示的静态空终止字符串的指针。该字符串可以在asctime和之间共享ctime,并且可以在每次调用这些函数时被覆盖。

    2)成功时为零(在这种情况下,时间的字符串表示已经写入到所指向的数组buffer),或者在失败时为非零(在这种情况下,终止空字符总是被写入,buffer[0]除非buffer是空指针或者bufsz是零或大于RSIZE_MAX。

    笔记

    ctime返回一个指向静态数据的指针并且不是线程安全的。此外,它修改静态tm其可以与共享对象gmtime和localtime。POSIX将此功能标记为废弃,并推荐strftime使用。C标准也建议strftime不要使用ctime,ctime_s因为strftime它更灵活且对语言环境敏感。

    ctimetime_t的值的行为可能未定义,导致字符串长于25个字符(例如,年份10000)。

    #define __STDC_WANT_LIB_EXT1__ 1

    #include

    #include

    int main(void)

    {

    time_t result = time(NULL);

    printf("%s", ctime(&result));

    #ifdef __STDC_LIB_EXT1__

    char str[26];

    ctime_s(str,sizeof str,&result);

    printf("%s", str);

    #endif

    }

    输出:

    Tue May 26 21:51:03 2015

    Tue May 26 21:51:03 2015

    参考

    C11标准(ISO / IEC 9899:2011): 7.27.3.2 ctime函数(p:393)

    K.3.8.2.2 ctime_s函数(p:626)

    C99标准(ISO / IEC 9899:1999): 7.23.3.2 ctime函数(p:342)

    C89 / C90标准(ISO / IEC 9899:1990): 4.12.3.2 ctime函数

    展开全文
  • C语言头文件 CTIME

    2022-06-11 11:24:37
    C语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 CTIMEC语言头文件 ...
  • 本文整理匯總了Python中time.ctime方法的典型用法代碼示例。如果您正苦於以下問題:Python time.ctime方法的具體用法?Python time.ctime怎麽用?Python time.ctime使用的例子?那麽恭喜您, 這裏精選的方法代碼示例...

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

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

    示例1: load

    ​點讚 6

    # 需要導入模塊: 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,

    示例2: step

    ​點讚 6

    # 需要導入模塊: 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,

    示例3: info

    ​點讚 6

    # 需要導入模塊: 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,

    示例4: main

    ​點讚 6

    # 需要導入模塊: 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,

    示例5: main

    ​點讚 6

    # 需要導入模塊: 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,

    示例6: main

    ​點讚 6

    # 需要導入模塊: 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,

    示例7: get_file_meta_data

    ​點讚 6

    # 需要導入模塊: 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,

    示例8: save_grammar

    ​點讚 6

    # 需要導入模塊: 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,

    示例9: header_section

    ​點讚 6

    # 需要導入模塊: 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,

    示例10: run

    ​點讚 6

    # 需要導入模塊: 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,

    示例11: generate

    ​點讚 6

    # 需要導入模塊: 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,

    示例12: getwx

    ​點讚 6

    # 需要導入模塊: 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,

    示例13: run

    ​點讚 6

    # 需要導入模塊: 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,

    示例14: __init__

    ​點讚 6

    # 需要導入模塊: 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,

    示例15: crawl

    ​點讚 6

    # 需要導入模塊: 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,

    示例16: load_stats

    ​點讚 6

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def load_stats(self, arg):

    if not arg: self.stats = {}

    elif isinstance(arg, basestring):

    f = open(arg, 'rb')

    self.stats = marshal.load(f)

    f.close()

    try:

    file_stats = os.stat(arg)

    arg = time.ctime(file_stats.st_mtime) + " " + arg

    except: # in case this is not unix

    pass

    self.files = [ arg ]

    elif hasattr(arg, 'create_stats'):

    arg.create_stats()

    self.stats = arg.stats

    arg.stats = {}

    if not self.stats:

    raise TypeError, "Cannot create or construct a %r object from '%r''" % (

    self.__class__, arg)

    return

    開發者ID:glmcdona,項目名稱:meddle,代碼行數:22,

    示例17: flatten

    ​點讚 6

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def flatten(self, msg, unixfrom=False):

    """Print the message object tree rooted at msg to the output file

    specified when the Generator instance was created.

    unixfrom is a flag that forces the printing of a Unix From_ delimiter

    before the first object in the message tree. If the original message

    has no From_ delimiter, a `standard' one is crafted. By default, this

    is False to inhibit the printing of any From_ delimiter.

    Note that for subobjects, no From_ line is printed.

    """

    if unixfrom:

    ufrom = msg.get_unixfrom()

    if not ufrom:

    ufrom = 'From nobody ' + time.ctime(time.time())

    print >> self._fp, ufrom

    self._write(msg)

    開發者ID:glmcdona,項目名稱:meddle,代碼行數:19,

    示例18: _print_verbose

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def _print_verbose(*args):

    """Print diagnostic message."""

    try:

    return '{0} {1} ({2})'.format(args[0], args[1], ctime())

    except IndexError:

    return '{0} ({1})'.format(args[0], ctime())

    開發者ID:spencerahill,項目名稱:aospy,代碼行數:8,

    示例19: _atexit

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def _atexit():

    print("all done at:", ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:4,

    示例20: loop

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def loop(nloop, nsec):

    print('Start LOOP', nloop, 'at:', ctime())

    sleep(nsec)

    print('LOOP', nloop, 'DONE at:', ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:6,

    示例21: run

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def run(self):

    print('starting', self.name, 'at:', ctime())

    self.res = self.func(*self.args)

    print(self.name, 'finished at:', ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:6,

    示例22: main

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def main():

    print('At {} on Amazon...'.format(ctime()))

    for isbn in ISBNs:

    # use multi thread

    Thread(target=_showRanking, args=(isbn,)).start()

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:7,

    示例23: loop

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def loop(nsec):

    myname = currentThread().name

    with lock:

    remaining.add(myname)

    print("[{}] Started {}".format(ctime(), myname))

    sleep(nsec)

    with lock:

    remaining.remove(myname)

    print("[{}] Completed {} ({} secs)".format(ctime(), myname, nsec))

    print(" (remaining: {})".format(remaining or "None"))

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:12,

    示例24: _atexit

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def _atexit():

    print("all Done at", ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:4,

    示例25: loop0

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def loop0():

    print('開始 Loop 0,當前時間', ctime())

    sleep(4)

    print('Loop 0 結束,當前時間', ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:6,

    示例26: loop1

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def loop1():

    print('開始 Loop 1,當前時間', ctime())

    sleep(2)

    print('Loop 1 結束,當前時間', ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:6,

    示例27: main

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def main():

    print('程序開始,當前時間', ctime())

    loop0()

    loop1()

    print('程序結束,當前時間', ctime())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:7,

    示例28: _main

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def _main():

    print("starging at:", ctime())

    nloops = randrange(2, 6)

    print("THE CANDY MACHINE (full with %d bars)!" % MAX)

    Thread(

    target=consumer, args=(randrange(nloops, nloops + MAX + 2),)

    ).start() # buyer

    Thread(target=producer, args=(nloops,)).start() # vndr

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:10,

    示例29: dataReceived

    ​點讚 5

    # 需要導入模塊: import time [as 別名]

    # 或者: from time import ctime [as 別名]

    def dataReceived(self, data):

    message = '[%s] %s' % (ctime(), data)

    self.transport.write(message.encode())

    開發者ID:wdxtub,項目名稱:deep-learning-note,代碼行數:5,

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

    展开全文
  • 本文整理汇总了Python中stat.ST_CTIME属性的典型用法代码示例。如果您正苦于以下问题:Python stat.ST_CTIME属性的具体用法?Python stat.ST_CTIME怎么用?Python stat.ST_CTIME使用的例子?那么恭喜您, 这里精选的...

    本文整理汇总了Python中stat.ST_CTIME属性的典型用法代码示例。如果您正苦于以下问题:Python stat.ST_CTIME属性的具体用法?Python stat.ST_CTIME怎么用?Python stat.ST_CTIME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块stat的用法示例。

    在下文中一共展示了stat.ST_CTIME属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

    示例1: fetch

    ​点赞 6

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def fetch(self, is_dl_forced=False):

    '''connection details for DISCO'''

    cxn = {}

    cxn['host'] = 'nif-db.crbs.ucsd.edu'

    cxn['database'] = 'disco_crawler'

    cxn['port'] = '5432'

    cxn['user'] = config.get_config()['user']['disco']

    cxn['password'] = config.get_config()['keys'][cxn['user']]

    pg_iri = 'jdbc:postgresql://'+cxn['host']+':'+cxn['port']+'/'+cxn['database']

    self.dataset.set_ingest_source(pg_iri)

    # process the tables

    # self.fetch_from_pgdb(self.tables,cxn,100) #for testing

    self.fetch_from_pgdb(self.tables, cxn)

    self.get_files(is_dl_forced)

    fstat = os.stat('/'.join((self.rawdir, 'dvp.pr_nlx_157874_1')))

    filedate = datetime.utcfromtimestamp(fstat[ST_CTIME]).strftime("%Y-%m-%d")

    self.dataset.set_ingest_source_file_version_date(pg_iri, filedate)

    开发者ID:monarch-initiative,项目名称:dipper,代码行数:24,

    示例2: test_version_level_source_version_download_timestamp

    ​点赞 6

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def test_version_level_source_version_download_timestamp(self):

    path_to_dl_file = '/'.join(

    (self.source.rawdir, self.source.files.get('test_file').get('file')))

    fstat = os.stat(path_to_dl_file)

    self.downloaded_file_timestamp = \

    datetime.utcfromtimestamp(fstat[ST_CTIME]).strftime("%Y%m%d")

    triples = list(self.source.dataset.graph.triples(

    (URIRef(self.theseFiles.get("test_file").get("url")),

    self.iri_retrieved_on,

    None)))

    self.assertTrue(len(triples) == 1,

    "missing triple for ingest file retrieved on " +

    "(download timestamp)")

    self.assertEqual(Literal(triples[0][2], datatype=XSD.date),

    Literal(self.downloaded_file_timestamp, datatype=XSD.date),

    "version level source version timestamp isn't " +

    "the same as the download timestamp of the local file")

    开发者ID:monarch-initiative,项目名称:dipper,代码行数:21,

    示例3: test_postgres_version_level_source_version_download_timestamp

    ​点赞 6

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def test_postgres_version_level_source_version_download_timestamp(self):

    path_to_dl_file = '/'.join(

    (self.pg_source.rawdir, self.pg_source.files.get('test_file').get('file')))

    fstat = os.stat(path_to_dl_file)

    self.downloaded_file_timestamp = \

    datetime.utcfromtimestamp(fstat[ST_CTIME]).strftime("%Y%m%d")

    triples = list(self.pg_source.dataset.graph.triples(

    (URIRef(self.theseFiles.get("test_file").get("url")),

    self.iri_retrieved_on,

    None)))

    self.assertTrue(len(triples) == 1,

    "missing triple for ingest file retrieved on " +

    "(download timestamp)")

    self.assertEqual(Literal(triples[0][2], datatype=XSD.date),

    Literal(self.downloaded_file_timestamp, datatype=XSD.date),

    "version level source version timestamp isn't " +

    "the same as the download timestamp of the local file")

    开发者ID:monarch-initiative,项目名称:dipper,代码行数:21,

    示例4: show_statistics

    ​点赞 6

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def show_statistics(self):

    """Show general file and table statistics

    """

    print "# File Statistics:"

    file_stats = os.stat(self.frm_path)

    file_info = {

    'Size': file_stats[stat.ST_SIZE],

    'Last Modified': time.ctime(file_stats[stat.ST_MTIME]),

    'Last Accessed': time.ctime(file_stats[stat.ST_ATIME]),

    'Creation Time': time.ctime(file_stats[stat.ST_CTIME]),

    'Mode': file_stats[stat.ST_MODE],

    }

    for value, data in file_info.iteritems():

    print "#%22s : %s" % (value, data)

    print

    # Fail if we cannot read the file

    try:

    self.frm_file = open(self.frm_path, "rb")

    except Exception, error:

    raise UtilError("The file %s cannot be read.\n%s" %

    (self.frm_path, error))

    # Read the file type

    开发者ID:mysql,项目名称:mysql-utilities,代码行数:27,

    示例5: gen_folder_listing

    ​点赞 6

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def gen_folder_listing(path):

    l = os.listdir(path)

    s = '<?xml version="1.0"?>\n\n'

    for i in l:

    objpath = os.path.join(path, i)

    if os.path.isdir(objpath):

    args = (i, unix2bluetime(os.stat(objpath)[stat.ST_CTIME]))

    s += ' ' % args

    else:

    args = (i, unix2bluetime(os.stat(objpath)[stat.ST_CTIME]),

    os.stat(objpath)[stat.ST_SIZE])

    s += ' ' % args

    s += "\n"

    if sys.version_info.major < 3:

    s = unicode(s)

    return s

    开发者ID:nccgroup,项目名称:nOBEX,代码行数:22,

    示例6: get_file_info

    ​点赞 5

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def get_file_info(system, path, verbose=False):

    fullpath = get_fullpath(system, path)

    if fullpath == IO_ERROR:

    return IO_ERROR

    result = {}

    if system.startswith('/'): # local or sub

    if can_read(system, path):

    # TODO platform-specific

    stats = os.stat(fullpath)

    stm = stats.st_mode

    result['type'] = get_file_type_char(stat.S_IFMT(stm))

    result['permissions'] = '%o' % (stat.S_IMODE(stm))

    result['UID'] = stats[stat.ST_UID]

    result['GID'] = stats[stat.ST_GID]

    result['ATIME'] = stats[stat.ST_ATIME]

    result['MTIME'] = stats[stat.ST_MTIME]

    result['CTIME'] = stats[stat.ST_CTIME] # actually mtime on UNIX, TODO

    else:

    if verbose:

    log.info('File \'%s\' is not accessible.' % (fullpath))

    result['type'] = None

    result['permissions'] = None

    result['UID'] = None

    result['GID'] = None

    result['ATIME'] = None

    result['MTIME'] = None

    result['CTIME'] = None

    return result

    else: # SSH/FTP/TFTP/HTTP

    # TODO NOT IMPLEMENTED

    return IO_ERROR

    开发者ID:lightfaith,项目名称:locasploit,代码行数:35,代码来源:io.py

    示例7: getctime

    ​点赞 5

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def getctime(self):

    st = self.statinfo

    if not st:

    self.restat()

    st = self.statinfo

    return st[ST_CTIME]

    开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:8,

    示例8: get

    ​点赞 4

    # 需要导入模块: import stat [as 别名]

    # 或者: from stat import ST_CTIME [as 别名]

    def get(self, socket, request):

    name = ""

    req_type = ""

    for header in request.header_data:

    if isinstance(header, headers.Name):

    name = header.decode().strip("\x00")

    self.logger.info("Receiving request for {}".format(name))

    elif isinstance(header, headers.Type):

    req_type = header.decode().strip("\x00")

    self.logger.info("Request type: {}".format(req_type))

    path = os.path.abspath(os.path.join(self.directory, name))

    if os.path.isdir(path) or req_type == "x-obex/folder-listing":

    if path.startswith(self.directory):

    filelist = os.listdir(path)

    s = '<?xml version="1.0"?>\n\n'

    for i in filelist:

    objpath = os.path.join(path, i)

    if os.path.isdir(objpath):

    s += ' '.format(i, os.stat(objpath)[stat.ST_CTIME])

    else:

    s += ' '.format(

    i, os.stat(objpath)[stat.ST_CTIME], os.stat(objpath)[stat.ST_SIZE])

    s += "\n"

    self.logger.debug('Bluetooth get XML output:\n' + s)

    response = responses.Success()

    response_headers = [headers.Name(name.encode("utf8")),

    headers.Length(len(s)),

    headers.Body(s.encode("utf8"))]

    BrowserServer.send_response(self, socket, response, response_headers)

    else:

    self._reject(socket)

    else:

    self._reject(socket)

    # vim:sw=4:ts=4:et:

    开发者ID:BlackLight,项目名称:platypush,代码行数:44,

    注:本文中的stat.ST_CTIME属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

    展开全文
  • NULL 博文链接:https://hbiao68.iteye.com/blog/2167353
  • CTime的用法总结

    千次阅读 2022-01-02 13:17:44
    需要注意的是,GetCurrentTime() 是静态方法,所以其不属于CTime对象,需要加 CTime:: 来调用该静态方法,其定义如下: // atltime.inl ATLTIME_INLINE CTime WINAPI CTime::GetCurrentTime() throw() { return( ...
  • ctime库函数的使用

    2020-07-28 10:14:40
    ctime库函数的使用 目录 ctime库函数的使用 一、基本概念的理解: 二、与日期和时间相关的数据结构 三、与日期和时间相关的函数及应用 获得日历时间 2 .获得日期和时间 固定的时间格式 4 计算持续时间的长度 5 ...
  • CTime用法

    2021-05-25 14:41:28
    CTime time = CTime::GetCurrentTime(); int a = time.GetYear();//得到年(1970年~2038年) int b = time.GetMonth();//得到月 int c = time.GetDay();//得到日 int d = time.GetHour();//得到时 int e = time....
  • 一个CTime类.

    2013-09-23 20:40:54
    一个CTime类.一个CTime类.一个CTime类.一个CTime类.一个CTime类.
  • vc ++ 常用CTime相关

    2020-03-24 22:44:08
    CTime time time_t
  • C/C++中的ctime用法总结

    千次阅读 2021-04-16 13:17:52
    时间转换函数 5个时间转换函数功能如下: 函数 说明 asctime tm 转 string ctime time_t 转 string gmtime UTC时间的time_t 转 tm localtime 本地时间的time_t 转 tm strftime 格式化为string mktime tm 转time_t ...
  • ctime>头文件

    千次阅读 2020-08-06 11:34:24
    ctime 头文件“时间”和“日期”的概念Coordinated Universal Time(UTC):Calendar Time:clock tick:重要的宏CLOCKS_PER_SECclock_ttime_t重要数据类型struct tm函数clock 函数difftime 函数time 函数mktime 函数...
  • Linux平台的ctime()函数

    2021-05-13 07:02:54
    想到应该是在向数据库插入数据时使用的是ctime()函数,记得这个函数返回的const char *末尾有一个\n(换行符)。man手册给出ctime()说明:It converts the calendar time t into a null-terminated string of ...
  • __CRT_INLINE char *__cdecl ctime(const time_t *_Time); __CRT_INLINE struct tm *__cdecl gmtime(const time_t *_Time); ctime函数   ctime函数可以将当前时间值转换为字符串格式返回。返回的字符串格式为:...
  • Linux系统文件中三个主要的时间属性:atime(access time)mtime(modify time)ctime(change time)这三个时间很容易混淆,须加以区分atime(access time):在读取文件或者执行文件时更改,即文件最后一次被读取或执行的...
  • 一、DateTimePicker控件引用一个DateTimePicker控件,关联变量m_date为DateTimeCtrl类型,然后在响应事件中加入如下代码:CTime tm;m_date.GetTime(tm);CString strDate=tm.Format("%Y-%m-%d");就可以获取了...但是不知...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 185,036
精华内容 74,014
关键字:

ctime