pythonコードノートの学習

3572 ワード

string.strip()末尾指定文字のデフォルトスペースを削除
a = "   112,   12313   ,   1231"
a = a.split(',').strip()
print(a)

#     
a = a.split(',').strip()
AttributeError: 'list' object has no attribute 'strip'


a = "   112   ,   12313   ,   1231"
a = a.strip().split(',')
print(a)
#  
['112   ', '   12313   ', '   1231']

list.extend()
extend()関数は、リストの最後に別のシーケンスの複数の値を一度に追加するために使用されます(新しいリストで元のリストを拡張します).
collection.Counter( stringTest ).most_common()
Counterカウンタを用いてstringTsetで最も一般的な文字結果を計算する例:[(‘e’,3),(‘d’,2),(‘b’,1),(‘c’,1),(‘a’,1)]
for ifコンビネーション文とCounterを組み合わせて低周波語彙をフィルタリングする
[item for item in collections.Counter(words).most_common() if item[1] >= min_count

for _ in range(10):
for _ in range(10):
    _ +=1
    print(_)
    _ = 1
    #   1 10
  # _                       ,        
  #                    range(10)   

dict() list()
空の辞書空のリスト
pytestモード?
リファレンスマニュアルhttps://docs.pytest.org/en/latest/contents.html