1
A
回答
5
檢查正在使用的Python的版本;變量sys.version
包含有用的信息。
即在Python 3.x的無效,因爲print
是隻是一個正常功能,因此需要括號:
# valid Python 3.x syntax ..
def x(bruce): print(bruce, bruce)
x("chin")
# .. but perhaps "cleaner"
def x(bruce):
print(bruce, bruce)
(在Python 2.x的行爲是不同的,where print
was a special statement)
+0
top show pst,top show,cheers pal。 –
3
你似乎在試圖打印不正確。
你可以使用一個元組:
def p(bruce):
print (bruce, bruce) # print((bruce, bruce)) should give a tuple in python 3.x
或者你可以在Python中〜2.7字符串使用格式:
def p(bruce):
print "{0}{1}".format(bruce, bruce)
或者在Python 3中使用函數:
def p(bruce):
print("{0}{1}".format(bruce, bruce))
相關問題
- 1. print()Python3.2中的SyntaxError?
- 2. SyntaxError:調用'print'時缺少小括號
- 3. 附近有語法錯誤('附近「=」
- 4. NSRangeException附近的NSData
- 5. SyntaxError:不匹配的輸入'print'期望INDENT
- 6. android.database.sqlite.SQLiteException:在「...」附近
- 7. PKG_CHECK_MODULES附近luajit
- 8. 附近今天
- 9. 附近@parameter
- 10. 附近圖像
- 11. 如何附近
- 12. 附近TD
- 13. 附近位置
- 14. 在附近
- 15. 當附近scipy.spatial.Delaunay
- 16. 附近其父
- 17. 谷歌附近的通知不顯示當我附近beacone
- 18. Geonames在附近找到附近的地方
- 19. dbo.StoredProcedure'SELECT'附近的SQL語法錯誤'AS'附近
- 20. PSQLException:附近或「實體」附近的語法錯誤 - Spring Boot
- 21. ksh print命令顯示附加字符
- 22. 找到附近BloodBanks
- 23. execSQL SQLiteException在「?」附近
- 24. mongodb geo附近與
- 25. 使用$附近以$
- 26. 附近獲得HREF
- 27. 附近的位置通知
- 28. 掃描附近的手機
- 29. Foursquare附近的地方
- 30. 的SQLite錯誤附近「WITH」
啊,只需添加一個回報有冒號後,不知道爲什麼這樣做,語法錯誤是第一次布魯斯文中陳述部分 –
檢查您的Python版本。這在Python 3.x中是無效的,因爲'print'只是一個函數。 – 2012-09-26 01:54:32
其3.2.3根據空閒 –