Python - TK-CTF/CTF GitHub Wiki

Python

  • version Python 3.7

Module

  • requests
  • string

Grammar

  • 文字列 'Single' "Double"
  • 出力 print('Hello World')
  • 四則演算 + - * / %
  • 文字列の連結 "Py" + "thon"
  • 型変換 str(50) int("100")
  • 条件式
if 0 == 0:
  print("always true")
elif 0 > 1:
  print("always false")
else:
  print("unknown")
  • 真偽値 真 TrueFalse
  • 述語記号 == != > >= < <=
  • 論理記号 and or not
  • 入力 input("push any key...")
  • リスト list = ["Hello", "My", "Birthday", "Is", 10, "/", 17]
    • 参照 list[0]
    • 追加 list.append(2019)
    • スライス記法 a = [1,2,3,4,5] s = a[1:3] (s = [1,2,3])

Tips

  • べき乗の計算で,
m = c ** d % n

m = pow(c, d, n)

は同じ結果を出すが,下のほうがかなり速い.