久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

<i id='Lu7b1'><tr id='Lu7b1'><dt id='Lu7b1'><q id='Lu7b1'><span id='Lu7b1'><b id='Lu7b1'><form id='Lu7b1'><ins id='Lu7b1'></ins><ul id='Lu7b1'></ul><sub id='Lu7b1'></sub></form><legend id='Lu7b1'></legend><bdo id='Lu7b1'><pre id='Lu7b1'><center id='Lu7b1'></center></pre></bdo></b><th id='Lu7b1'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Lu7b1'><tfoot id='Lu7b1'></tfoot><dl id='Lu7b1'><fieldset id='Lu7b1'></fieldset></dl></div>
        <bdo id='Lu7b1'></bdo><ul id='Lu7b1'></ul>

    1. <legend id='Lu7b1'><style id='Lu7b1'><dir id='Lu7b1'><q id='Lu7b1'></q></dir></style></legend>

    2. <tfoot id='Lu7b1'></tfoot>

      <small id='Lu7b1'></small><noframes id='Lu7b1'>

      1. Python:用微秒將字符串轉換為時間戳

        Python: Converting string to timestamp with microseconds(Python:用微秒將字符串轉換為時間戳)

          <i id='CKGD6'><tr id='CKGD6'><dt id='CKGD6'><q id='CKGD6'><span id='CKGD6'><b id='CKGD6'><form id='CKGD6'><ins id='CKGD6'></ins><ul id='CKGD6'></ul><sub id='CKGD6'></sub></form><legend id='CKGD6'></legend><bdo id='CKGD6'><pre id='CKGD6'><center id='CKGD6'></center></pre></bdo></b><th id='CKGD6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='CKGD6'><tfoot id='CKGD6'></tfoot><dl id='CKGD6'><fieldset id='CKGD6'></fieldset></dl></div>
              <bdo id='CKGD6'></bdo><ul id='CKGD6'></ul>

                • <small id='CKGD6'></small><noframes id='CKGD6'>

                • <tfoot id='CKGD6'></tfoot>

                  <legend id='CKGD6'><style id='CKGD6'><dir id='CKGD6'><q id='CKGD6'></q></dir></style></legend>
                    <tbody id='CKGD6'></tbody>
                  本文介紹了Python:用微秒將字符串轉換為時間戳的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想將字符串日期格式轉換為以微秒為單位的時間戳我嘗試以下但未給出預期結果:

                  I would like to convert string date format to timestamp with microseconds I try the following but not giving expected result:

                  """input string date -> 2014-08-01 04:41:52,117
                  expected result -> 1410748201.117"""
                  
                  import time
                  import datetime
                  
                  myDate = "2014-08-01 04:41:52,117"
                  timestamp = time.mktime(datetime.datetime.strptime(myDate, "%Y-%m-%d %H:%M:%S,%f").timetuple())
                  
                  print timestamp
                  > 1410748201.0
                  

                  毫秒去哪兒了?

                  推薦答案

                  時間元組中沒有微秒組件的槽:

                  There is no slot for the microseconds component in a time tuple:

                  >>> import time
                  >>> import datetime
                  >>> myDate = "2014-08-01 04:41:52,117"
                  >>> datetime.datetime.strptime(myDate, "%Y-%m-%d %H:%M:%S,%f").timetuple()
                  time.struct_time(tm_year=2014, tm_mon=8, tm_mday=1, tm_hour=4, tm_min=41, tm_sec=52, tm_wday=4, tm_yday=213, tm_isdst=-1)
                  

                  您必須手動添加:

                  >>> dt = datetime.datetime.strptime(myDate, "%Y-%m-%d %H:%M:%S,%f")
                  >>> time.mktime(dt.timetuple()) + (dt.microsecond / 1000000.0)
                  1406864512.117
                  

                  您可以遵循的另一種方法是生成 timedelta() 對象 相對于紀元,然后使用 timedelta.total_seconds() 方法:

                  The other method you could follow is to produce a timedelta() object relative to the epoch, then get the timestamp with the timedelta.total_seconds() method:

                  epoch = datetime.datetime.fromtimestamp(0)
                  (dt - epoch).total_seconds()
                  

                  本地時間紀元的使用是經過深思熟慮的,因為您有一個幼稚的(不是時區感知的)日期時間值.此方法可能根據您當地時區的歷史記錄不準確,但請參閱 JF塞巴斯蒂安的評論.您必須先使用本地時區將原始日期時間值轉換為可識別時區的日期時間值,然后再減去可識別時區的紀元.

                  The use of a local time epoch is quite deliberate since you have a naive (not timezone-aware) datetime value. This method can be inaccurate based on the history of your local timezone however, see J.F. Sebastian's comment. You'd have to convert the naive datetime value to a timezone-aware datetime value first using your local timezone before subtracting a timezone-aware epoch.

                  因此,堅持 timetuple() + 微秒的方法更容易.

                  As such, it is easier to stick to the timetuple() + microseconds approach.

                  演示:

                  >>> dt = datetime.datetime.strptime(myDate, "%Y-%m-%d %H:%M:%S,%f")
                  >>> epoch = datetime.datetime.fromtimestamp(0)
                  >>> (dt - epoch).total_seconds()
                  1406864512.117
                  

                  這篇關于Python:用微秒將字符串轉換為時間戳的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  python: Two modules and classes with the same name under different packages(python:不同包下同名的兩個模塊和類)
                  Configuring Python to use additional locations for site-packages(配置 Python 以使用站點包的其他位置)
                  How to structure python packages without repeating top level name for import(如何在不重復導入頂級名稱的情況下構造python包)
                  Install python packages on OpenShift(在 OpenShift 上安裝 python 包)
                  How to refresh sys.path?(如何刷新 sys.path?)
                  Distribute a Python package with a compiled dynamic shared library(分發帶有已編譯動態共享庫的 Python 包)
                  <tfoot id='vJw3C'></tfoot>
                    <bdo id='vJw3C'></bdo><ul id='vJw3C'></ul>
                  • <small id='vJw3C'></small><noframes id='vJw3C'>

                    <legend id='vJw3C'><style id='vJw3C'><dir id='vJw3C'><q id='vJw3C'></q></dir></style></legend>
                      <i id='vJw3C'><tr id='vJw3C'><dt id='vJw3C'><q id='vJw3C'><span id='vJw3C'><b id='vJw3C'><form id='vJw3C'><ins id='vJw3C'></ins><ul id='vJw3C'></ul><sub id='vJw3C'></sub></form><legend id='vJw3C'></legend><bdo id='vJw3C'><pre id='vJw3C'><center id='vJw3C'></center></pre></bdo></b><th id='vJw3C'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vJw3C'><tfoot id='vJw3C'></tfoot><dl id='vJw3C'><fieldset id='vJw3C'></fieldset></dl></div>
                              <tbody id='vJw3C'></tbody>
                            主站蜘蛛池模板: 色哟哟一区二区三区 | 日韩欧美视频 | 欧美极品在线 | 国产xxx| 久久精品在线播放 | 99久久精品一区二区成人 | 成av人片在线观看www | 福利片在线 | 欧美精品综合 | 亚洲激情视频在线观看 | 亚洲欧美精品一区二区 | 成人观看视频 | 久久视频这里只有精品 | 欧洲av在线| 美女免费视频网站 | 国产三级久久 | 久久精品欧美一区 | 怡红院久久 | 五月精品| 俺去俺来也在线www色官网 | 日韩成人中文字幕 | 中文字幕免费看 | 国产精品一区二区不卡 | 国产午夜免费 | 91av在线播放 | 亚洲影院在线 | 日韩毛片视频 | 免费性网站 | 欧美黄色一区二区 | 99精品久久久久久 | 精品一区二区三区四区五区 | 成人婷婷 | 黄色激情网站 | 色综合色综合色综合 | 一区二区三区网站 | 三级福利视频 | 中国第一毛片 | 日韩久久久 | 69成人网 | 国产激情一区二区三区 | 五月网站|