Python----変数のフォーマット

673 ワード

Pythonでprint関数を使用してコンソールに情報を出力できます
フォーマットオペレータ:%文字列に特化したフォーマット
%s       
%d            。%06d            ,    0  
%f       。 %0.2f           
%%      %。 50%  = 50%% 
 
 
print("      " %   1)
print("      " % (  1,   2...))
 
print('name %s' % input('name:'))
print('age %02d' % int(input('age:')))
print('price %.02f' % float(input('price:')))
print('percen %.02f%%' % float(input('percen:')))

折り返し
print("*")           #        
print("*", end="")    #      
print("*", end="--")  #         :--