http://phpy.readthedocs.org/en/latest/string.html

関連する外部ページ】: https://chiraura.hhiro.net/?page=Python%CA%D9%B6%AF%CD%D1%A5%E1%A5%E2

ライブラリ

IPyton,

制御構造

if, elif, else, while, break, for

単純値のデータ型

int, float, None, str, bytes, dict, set

文字列の演算子

+, in, %, split, join, replace, strip,

関数定義、関数オブジェクト

コンテナ

list, range, tuple

ヒアドキュメント 「"""」で始まり、「"""」だけの行で終わる。

リダイレクト redirect

# リダイレクト(上書き).Unixだと '>'
>>> file = open('test.txt', 'w')
>>> print >> file, 'test output2'
>>> file.close()
>>> open('test.txt', 'r').read()
'test output2\n'

# リダイレクト(追記). Unixだと '>>'
>>> file = open('test.txt', 'a')
>>> print >> file, 'test output3'
>>> file.close()
>>> open('test.txt', 'r').read()
'test output2\ntest output3\n'

Flamework flask

from flask import Flask
app = Flask(__name__)
 
@app.route("/")
def hello():
    return "Hello World!"
 
if __name__ == "__main__":
    app.run()
http://127.0.0.1:5000/

OS command

import commands
result=commands.getoutput('la -a')