Skip to Content
Python 技術手冊 第三版
book

Python 技術手冊 第三版

by lex Martelli, Anna Martelli Ravenscroft, Steve Holden
January 2018
Intermediate to advanced
856 pages
17h 17m
Chinese
GoTop Information, Inc.
Content preview from Python 技術手冊 第三版
字串格式化
|
279
8-4 
格式型別 格式化說明
'b'
二進位(binary)格式,一系列的零與一
'c'
其序數值(ordinal value)是被格式化的值的 Unicode 字元
'd'
十進位(decimal,預設的格式型別)
'o'
八進位(octal)格式,一系列的八進位數字
'x'
'X'
十六進位(hexadecimal)格式,一系列的十六進位數字,帶有小寫或
大寫的字母
'n'
十進位格式,有設定系統的地區設定(system locale)的話,就帶有地
區特定(locale-specific)的分隔符(UK US 的逗號)
浮點數(floating-point numbers)具有不同的一組格式型別,如表 8-5
所示。
8-5 
格式型別 格式化說明
'e'
'E'
指數(exponential)格式,科學記號(scientific notation),帶有介於
一與九之間的整數部分,在指數前使用
'e'
'E'
'f'
'F'
定點(fixed-point)格式,可能會有大寫或小寫的無限(
'inf'
)或非數
字(
'nan'
'g'
'G'
通用(general)格式,可能的話就用定點格式,否則就用指數格式;依
據格式型別的大小寫使用小寫或大寫的
'e'
'inf'
'nan'
'n'
就像通用格式,但在有設定系統地區設定時,使用地區特定的分隔符來
為數字分組或用於小數點
'%'
百分比(percentage)格式,將值乘以 100 並將之格式化為後面接著
'%'
的定點格式
若沒指定格式型別,一個
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

利用 Python 进行数据分析(原书第2版)

利用 Python 进行数据分析(原书第2版)

Wes McKinney

Publisher Resources

ISBN: 9789864766819