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 技術手冊 第三版
50
|
3 章 Python 語言
一個
指定
assignment
是將值(values)指定給變數(variables)的簡單
述句,如我們會在後面「指定述句」中討論的。Python 中的指定是一個述
句,而且永遠都不能是運算式的一部分。
複合述句
一個
複合述句
compound statement
含有一或多個其他述句,並會控制
它們的執行。一個複合述句有一或多個等量縮排的
子句
clauses
。每個
子句都有以一個關鍵字開頭並以一個冒號(
:
)結尾的
標頭
header
,後
面接著一個
主體
body
,它是一或多個述句所成的一個序列。若主體含
有多個述句,也稱為一個
區塊
block
,那些述句就會在標頭行後面分別
的邏輯文字行中,以四個空格向右縮排。當縮排回到與子句標頭相同的量
(或更往左,到達某個外層複合述句的縮排量),那個區塊在語法上就算
結束。又或者是,主體可以是單一個簡單述句,接在
:
之後,與標頭位於
同一個邏輯文字行。主體也可能由同一行上,其間以分號區隔的數個簡單
述句所構成,但就如我們已經提過的,這並非良好的 Python 風格。
資料型別
Python 程式所進行的作業取決於它所處理的資料。在 Python 中,資料值
data values)被稱為
物件
objects
,而每個物件,也就是
value
都有一個
型別
type
。一個物件的型別決定該物件支援哪些作業(換句
話說,就是你可以對該值進行哪些運算)。型別也決定了該物件的
屬性
attributes
和(如果有的話)
項目
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