のPython 3.2はTypeError:%のためのサポートされていないオペランド(S): 'NoneType' と 'str' は
my_name = 'Joe Bloggs'
my_age = 25
my_height = 71 # inches
my_weight = 203 #lbs approximate, converted from ~14.5 stones
my_eyes = 'Blue'
my_teeth = 'White'
my_hair = 'Brown'
print("Let's talk about %s") % my_name
print ("He's %d inches tall.") % my_height
print ("He's %d pounds heavy.") % my_weight
print ("Actually that's not too heavy")
print ("He's got %s eyes and %s hair.") % (my_eyes, my_hair)
print ("His teeth are usually %s depending on the coffee.") % my_teeth
私は(9行目のエラーを取得する取得
TypeError:%: 'NoneType'と 'str'のためのサポートされていないオペランド
{0}と{0}を使用しようとしても、これを回避することができませんでした。フォーマット方法、任意のアイデア?
文字列の書式設定に '%'の代わりにstr.formatを使うべきです。なぜなら、これはpython 3.1で償却されており、今後削除されるからです。 – GWW
+1、完璧な答え。 (GWWが話していた部分を除いて:P) –
@GWWこれに対処するための答えに追加しました。 –