2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python

Last updated at Posted at 2019-05-26

FX

機械学習 gem利用方法

基本文法

len()
文字数カウント
str()
文字列に変換する
type()
型の判別
input()
gets
論理型
2 * 5 == 10
変数定義
number = "Hello World"
 dict = {"title": "ワンパン"}
  print(dict)

  print(dict["title"])
if
if value > 4:
 print("hello")

elif value == 3:
 print("ddd")

else:
 print("eveneing")
関数
def number_count():
  print("5")
  print("6")
  print("7")
  print("8")
  print("9")
  print("10")
文字列メソッド

startswith()
find()
rfind()
count()
capitalize()
title()
upper()
lower()
replace()
format
"a is {}".format("a")
→"a is a" 
"a is {0} {1} {2}".format(1,2,3)
→ a is 1 2 3
配列
pencil_case = ['apple', 'banana', 'parble']

追加
append

範囲

pencil_case[0:1] 
→'apple', 'banana'


pencil_case[:1]
→最初から1まで

pencil_case[1:]
→1から最後まで
 
クラスメソッド
 class クラス名:
    @classmethod
    def メソッド名(cls):
インスタンス作成
post = Post()
  post.write_post()
  post.show_post()

インスタンスメソッド
class クラス名:
    def メソッド名(self):
      # 処理
インスタンス変数定義
class クラス名
    def sample(self):
      self.text = "hoge"
イニシャライザー
class クラス名:
      def __init__(self, 引数):
          self.引数 #インスタンス変数の宣言。引数の値が変数の中身になる。
          print("クラス名のインスタンスが生成されました")


  インスタンス = クラス名() 

ゲッターセッター

継承

class 子クラス名(親クラス名):

class Post:

class PostDetail(Post):

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?