なぜ、このような無効な書式]?
-
13-09-2019 - |
質問
なぜことについて不服を申し立て無効な書式]?
#! /usr/bin/python
recipients = []
recipients.append('chris@elserinteractive.com')
for recip in recipients:
print recip
ん:
File "send_test_email.py", line 31
print recip
^
SyntaxError: invalid syntax
解決
あなたは、Pythonを使用している場合は、
3 print
機能です。このようにそれを呼び出します。print(recip)
他のヒント
Python3、印刷な声が 機能.
Old: print "The answer is", 2*2
New: print("The answer is", 2*2)
以python3 print
機能:
Old: print x, # Trailing comma suppresses newline
New: print(x, end=" ") # Appends a space instead of a newline
Old: print # Prints a newline
New: print() # You must call the function!
Old: print >>sys.stderr, "fatal error"
New: print("fatal error", file=sys.stderr)
Old: print (x, y) # prints repr((x, y))
New: print((x, y)) # Not the same as print(x, y)!
それは、Python 3だ場合は、
、print
は今の機能です。正しい構文は次のようになります。
print (recip)
所属していません StackOverflow