遍匈 / Python縮殻 /

Python忖憲堪

忖憲堪頁忖憲議匯倖會双?忖憲堪宥械峪頁匯堪汽簡。

壓低亟議耽匯倖Python殻會嶄脅勣聞喘忖憲堪?咀緩勣廣吭參和何蛍。

汽哈催

低辛參聞喘汽哈催箭泌'Quote me on this'峺協忖憲堪。侭嗤議腎易?箭泌腎鯉才崙燕憲脅梓圻劔隠藻。

褒哈催

壓褒哈催嶄議忖憲堪才壓汽哈催嶄議忖憲堪垢恬軟栖頼畠匯劔。箭泌"What's your name?"

眉嶷哈催

艇辛參聞喘眉嶷哈催-("""賜''')峺協謹佩忖憲堪。壓眉嶷哈催嶄艇辛參徭喇聞喘汽哈催才褒哈催。箭泌?
'''This is a multi-line string. This is the first line.
This is the second line.
"What's your name?," I asked.
He said "Bond, James Bond."
'''

忖憲堪頁音辛個延議

宸吭龍彭?匯稀艇厮将幹秀阻匯倖忖憲堪?低祥音嬬個延万。埋隼宸心軟栖貌窄頁匯周撒並?徽万寔音頁(撒並)。壓厘断朔中心欺議光嶽殻會嶄?繍氏苧易宸音頁匯倖尫崙。

C/C++殻會埀勣廣吭?壓Python嶄短嗤汽鏡議“char”(忖憲侏)方象。宸戦短嗤寔屎議俶勣万?厘屢佚低音氏危狛万。

Perl/PHP殻會埀勣廣吭?汽哈催忖憲堪才褒哈催忖憲堪頁屢揖議——麿断音參販採圭塀音揖。

鯉塀圭隈

嗤扮?厘断辛嬬?勣貫凪万佚連更秀忖憲堪。宸祥頁“format()”圭隈嗤喘岻侃。

隠贋和中叱佩欺猟周"str_format.py"嶄?
age = 20
name = 'Swaroop'
print('{0} was {1} years old when he wrote this book'.format(name, age))
print('Why is {0} playing with that python?'.format(name))
補竃?
$ python3 str_format.py
Swaroop was 20 years old when he wrote this book
Why is Swaroop playing with that python?

万頁泌採垢恬議?
匯倖忖憲堪辛參聞喘蒙協議鯉塀?昧朔距喘format圭隈?喘format圭隈紋旗椎乂聞喘癖輝歌方議鯉塀。

鉱賀聞喘及匯侃?厘断聞喘“{0}”斤哘噐延楚‘name’,宸頁format(鯉塀)圭隈議及匯倖歌方。窃貌議,及屈倖鯉塀頁“{1}”斤哘議“age”,宸頁鯉塀圭隈議及屈倖歌方。廣吭?Python貫0蝕兵柴方?宸吭龍彭及匯了崔議沫哈頁0?及屈倖了崔議沫哈頁1?吉吉。

廣吭?厘断辛參聞喘忖憲堪議銭俊?name+'is'+str(age)+'years old' 糞孖揖劔議朕議?徽宸掲械網凵、否叟竃危。及屈?壓宸嶽秤趨和?宥狛format圭隈徭強廬算葎忖憲堪?遇音頁?塋週慝Ĺ士đ菻ź鍔峽蔲?。及眉?輝聞喘議format 圭隈?厘断辛參個延嶧連?遇涙俶侃尖聞喘議延楚?郡岻呀隼。

珊勣廣吭?宸乂方忖(沫哈)脅頁辛僉議?侭參低匆辛參亟撹?
age = 20
name = 'Swaroop'
print('{} was {} years old when he wrote this book'.format(name, age))
print('Why is {} playing with that python?'.format(name))
宸繍公嚥念中議殻會屢揖議補竃。

Python壓format圭隈嶄恂議頁?喘耽倖歌方峙紋旗号鯉議仇圭。宸戦嗤厚峋聾議号鯉?泌?
decimal (.) precision of 3 for float '0.333'
>>> '{0:.3}'.format(1/3)
fill with underscores (_) with the text centered
(^) to 11 width '___hello___'
>>> '{0:_^11}'.format('hello')
keyword-based 'Swaroop wrote A Byte of Python'
>>> '{name} wrote {book}'.format(name='Swaroop', book='A Byte of Python')

AltStyle によって変換されたページ (->オリジナル) /