openしたファイルを出力先にしてprintすれば、それはsys.stdout.writelinesと同じような結果になりますね。
どういう風に二つを使い分けるのでしょうか?
またwritelinesとprintの関係にある関数はstdinにはありますか?
コード import sys f=open("outfile.txt",'w') sys.stdout=f sys.stdout.writelines(["A first line.\n","A second line\n"]) print("A line from the print function") sys.stdout=sys.__stdout__ f.close()

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/02/14 02:31