{"id":165323,"date":"2020-10-04T11:52:08","date_gmt":"2020-10-04T03:52:08","guid":{"rendered":"http:\/\/4563.org\/?p=165323"},"modified":"2020-10-04T11:52:08","modified_gmt":"2020-10-04T03:52:08","slug":"python-%e4%ba%8c%e8%bf%9b%e5%88%b6%e8%af%bb%e6%96%87%e4%bb%b6-%e8%bd%ac%e6%8d%a2-float-%e5%a4%b1%e8%b4%a5","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=165323","title":{"rendered":"Python \u4e8c\u8fdb\u5236\u8bfb\u6587\u4ef6 \u8f6c\u6362 float \u5931\u8d25"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  Python \u4e8c\u8fdb\u5236\u8bfb\u6587\u4ef6 \u8f6c\u6362 float \u5931\u8d25               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : woshichuanqilz <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>python \u4ee3\u7801<\/p>\n<pre><code>    sacfile = 'binfile'     f = open(sacfile, 'rb')     hdrBin = f.read()[:4]     print(hdrBin)     sfmt = 'f'     hdrFmt = struct.Struct(sfmt)     m_header = hdrFmt.unpack(hdrBin) <\/code><\/pre>\n<p>\u8f93\u51fa\u7ed3\u679c<\/p>\n<blockquote>\n<p>b'&lt;xa3xd7n&#8217;<\/p>\n<\/blockquote>\n<p>\u4f46\u662f\u6211\u7528 winhex \u67e5\u770b\u6e90\u6587\u4ef6 \u7b2c\u4e00\u4f4d\u662f 3C \u88ab\u8f6c\u6362\u6210 &#8216;&lt;&#8216; \u4e86 winhex \u524d\u516b\u4e2a\u5b57\u8282\u7684\u6570\u636e<\/p>\n<blockquote>\n<p>3CA3D70AC7572000<\/p>\n<\/blockquote>\n<p>\u95ee\u9898\u662f\u6211\u9700\u8981\u628a\u524d\u56db\u4e2a byte \u8f6c\u6362\u4e3a float \u6570\u636e, \u5c31\u662f&#8221;m_header&#8221;<\/p>\n<p>\u6211\u62ff\u5230\u7684\u7ed3\u679c\u662f\u9519\u7684: 2.0765148849577988e-32<\/p>\n<p>\u6b63\u786e\u7684\u7ed3\u679c\u5e94\u8be5\u662f: 0.02000000 \u8fd9\u4e2a\u95ee\u9898\u600e\u4e48\u89e3\u51b3?<\/p>\n<p>binfile \u5728\u8fd9\u91cc<\/p>\n<p>https:\/\/gitee.com\/lovelife_lizhe\/ori_data\/raw\/master\/binfile<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"3642913\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lcdtyph <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u7aef\u7eed\uff0csfmt \u6539\u4e00\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3642914\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lcdtyph <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5927\u7aef\u5e8f<br \/>@lcdtyph                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3642915\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : woshichuanqilz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lcdtyph Thanks \u5df2\u611f\u8c22                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"3642916\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : peonone <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u662f\u5927\u5c0f\u7aef\u7684\u95ee\u9898\uff0c\u6587\u4ef6\u662f\u5c0f\u7aef\u7684\uff0c\u4f60\u662f\u7528\u5927\u7aef\u7684\u683c\u5f0f\u8bfb\u51fa\u6765\u7684\uff0c\u628a sfmt \u6539\u6210&#8217;&gt;f&#8217;\u5c31\u80fd\u5f97\u51fa\u4f60\u8981\u7684\u7ed3\u679c<\/p>\n<p>\u81f3\u4e8e 3C \u548c'&lt;&#8216;, \u5185\u5bb9\u662f\u5b8c\u5168\u4e00\u6837\u7684\uff0c\u53ea\u662f Python \u5c06 3C \u8fd9\u4e2a\u5b57\u8282\u7528 ASCII \u7684\u5f62\u5f0f\u5c55\u73b0\u51fa\u6765\u800c\u5df2 b'&lt;&#8216;[0] == int(&#8216;3C&#8217;, 16)                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>Python \u4e8c\u8fdb\u5236\u8bfb\u6587\u4ef6 \u8f6c\u6362 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/165323"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=165323"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/165323\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=165323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=165323"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=165323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}