#目的
タイトルに書いた通りの
プログラムが必要になったからです
最後の項目にいくと
コピーだけすればいいようになっているので
すぐに使いたい方は
最後だけ見てくれればいいと思います
#ファイルの出力方法
以下のサイトを参照しました
以下のようにすると
同じディレクト内に
out.txtとしてssssと書いてあるテキストファイルが作られます
aの中身を別の文字にすると別の文字がout.txtに上書きされます
f = open('out.txt', 'w')
a = "ssss"
f.write(a)
f.close()
#リスト内からランダムに一つを選ぶ
以下のサイトを参照しました
randomモジュールをimportして
stringに50音をうちこみました
こちらのプログラムを使うと
ランダムで一文字がstringに入ります
import random
japanese_list = ["あ","い","う","え","お",\
"か","き","く","け","こ",\
"さ","し","す","せ","そ",\
"た","ち","つ","て","と",\
"な","に","ぬ","ね","の",\
"は","ひ","ふ","へ","ほ",\
"ま","み","む","め","も",\
"や","ゆ","よ",\
"ら","り","る","れ","ろ",\
"わ","を","ん"]
string_list = random.choice(japanese_list)
string = "".join(string_list)
#さぁこれでできます!!
丸ごとコピーしてください
import random
japanese_list = ["あ","い","う","え","お",\
"か","き","く","け","こ",\
"さ","し","す","せ","そ",\
"た","ち","つ","て","と",\
"な","に","ぬ","ね","の",\
"は","ひ","ふ","へ","ほ",\
"ま","み","む","め","も",\
"や","ゆ","よ",\
"ら","り","る","れ","ろ",\
"わ","を","ん"]
string_list = random.choice(japanese_list)
string = "".join(string_list)
#output part
f = open('string.txt', 'w')
f.write(string)
f.close()
これでstring.txtに文字が出力されたはずです!!