我嘗試讀取一個 json 檔案輸出給出奇怪的浮點數
250:4.918e-06
251:0.0006678
252:4.366e-07
253:3.0054e-06
254:3.0942e-05
我做錯了什么?
url= 'https://cryptobubbles.net/backend/data/currentBubbles1000.json'
user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'
headers={'User-Agent':user_agent,}
req= urllib.request.Request(url,None,headers)
teller = 0
def get_data_binance():
global teller
json_content = json.loads(urlopen(req).read())
for coins in json_content:
if coins['binanceSymbol'] and coins['data']['btc']['price']:
teller = 1
zeroteller = str(teller)
zero_filled_number = zeroteller.zfill(3)
binancefilled = coins['binanceSymbol']
#print(zero_filled_number ': ' binancefilled.ljust(12) ' ' str(coins['data']['usd']['price']))
print (zero_filled_number ': ' str(coins['data']['btc']['price']))
uj5u.com熱心網友回復:
4.918e-06 是一種科學記數法,用于數學、物理、化學、天文學和其他科學,用于處理非常大或非常小的數字。有了科學記數法,數字的加減乘除變得簡單多了。
4.918e-06 = 4.918 x 10 -6 = 0.000004918
另請參閱將科學記數法轉換為浮點數
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/383839.html
