Top/Lang/Python/基本文法

目次

スクリプトの先頭

関数

λ式

値の扱い

配列

負の配列 index

スライス

組み込み型

bool 型

True / False

文字列

文字列への代入

find() / rfind()

str_val.find(<検索したい文字列>, [開始インデックス], [終了インデックス] );

index() / rindex()

str_val.index(<検索したい文字列>, [開始インデックス], [終了インデックス] );

endwith()

str_val.endwith(<検索したい文字列>, [開始インデックス], [終了インデックス] );

startwidth()

str_val.startwidth(<検索したい文字列>, [開始インデックス], [終了インデックス] );

split() / rsplit()

str_val.split( [区切り文字], [分割数] );

join()

strip()

upper()

lower()

ljust()

文字のフォーマット

置換

ソート

sort()

revers()

remove()

append()

extend()

pop()

index()

リスト / list

リストの定義

スライス

リストの演算

a = [ 0, 1, 2 ]
b = [ 5, 6, 7 ]
c = a + b
print c
実行結果 -----------------------
[0, 1, 2, 5, 6, 7]

要素の追加

リストの掛け算

リスト要素の書き換え

要素の削除

リスト要素の検索

リストに存在するかどうかを調べる

リストの何番目の index にあるかを調べる

min / max

sort

set 型

dictionary

フロー制御

if

s = "snowsdutyrytrctyrhandwerwre";
if "hand" in s:  # 文字列の要素を検索
    print( "hand is found!" );

for

書式

for i in range(10, 21);
    # 処理...

 

range()

break

continue

while

class

Link

all

on MacOSX

on Windows


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2023-08-28 (月) 14:09:22