スキップしてメイン コンテンツに移動

投稿

ラベル(Python(English))が付いた投稿を表示しています

Handle space in Python

日本語ver Introduction Miss succeed Reference Introduction I want to display following print in Command line. apple   apple     apple       apple         apple Miss However, This print is not able to display following code used print script. def main () : i = 0 while i< 5 : print( 'apple' ) j = 0 while j < i: print( ' ' ) j = j + 1 i = i + 1 if __name__ == '__main__' : main() rusult… Print code change line when writing new apple. succeed Please, look at following code. import sys def main () : i = 0 while i < 5 : print( 'apple' ) j = 0 while j <= i: sys.stdout.write( ' ' ) j = j + 1 i = i + 1 if __name__ == '__main__' : main() sys.stdout.write is write string regardless of the changing line. Result! However, I give you a strong warning that s...