Python 引用符 リンクを取得 Facebook × Pinterest メール 他のアプリ 5月 05, 2020 引用符 ’(シングルクォーテーション) ”(ダブルクォーテーション) どちらも文字データを表す 文法上、シングルクォーテーション、ダブルクォーテーションの違いはなく、どちらを使ってもよい。 文字列の中にクォーテーションを含める場合、\(バックスラッシュ)でエスケープします。 文字列の中でシングルクォーテーションを使いたい場合はダブルクォーテーションで囲む、逆にダブルクォーテーションを使いたい場合はシングルクォーテーションで囲む。 例 # 単純な文字列 print('abc') print("def") # 文字列中にクォーテーションを含める print('これは"ダブルクォーテーション"') print("これが'シングルクォーテーション'") # クォーテーションをバックスラッシュでエスケープする print('abc\'def') print("abc\"def") 実行結果 abc def これは"ダブルクォーテーション" これが'シングルクォーテーション' abc'def abc"def リンクを取得 Facebook × Pinterest メール 他のアプリ コメント
Python while文 5月 09, 2020 while 文 指定した条件式が真の間、処理を繰り返し実行します。 while 条件式: 条件式が真の時に実行する文 例 number= 1 print ( "start" ) while number <= 10 : print (number) number = number + 1 print ( "end" ) 実行結果 start 1 2 3 4 5 6 7 8 9 10 end 続きを読む
Python for文 5月 09, 2020 for文 for 変数 in range (ループ回数): 実行する文 変数にを 開始、終了値がコードで明示されていない場合、 0からループ回数分その値を変数に設定する 例 for number in range ( 10 ): print (number) 実行結果 0 1 2 3 4 5 6 7 8 9 リストの場合 例 mylist = [ "Orange" , "Peach" , "Lemon" ] for val in mylist: print (val) print ( "End" ) 実行結果 Orange Peach Lemon 続きを読む
コメント
コメントを投稿