python for in文で文字列の1文字ずつ取得

2021年11月8日

構文
for 文字変数名 in 文字列:
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# coding: utf-8
str = 'testdata'
print("for文で1文字ずつ取得するサンプル")
for s in str:
print (s)
# coding: utf-8 str = 'testdata' print("for文で1文字ずつ取得するサンプル") for s in str: print (s)
# coding: utf-8

str = 'testdata'
print("for文で1文字ずつ取得するサンプル")
for s in str:
      print (s)

実行結果

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
for文で1文字ずつ取得するサンプル
t
e
s
t
d
a
t
a
for文で1文字ずつ取得するサンプル t e s t d a t a
for文で1文字ずつ取得するサンプル
t
e
s
t
d
a
t
a

 

Python

Posted by arkgame