簡體   English   中英

Python 打印使用 '' 代替 ()

[英]Python print use '' instead of ()

我正在閱讀 python 文件,作者使用 '' 而不是 () 來調用打印語句,例如:

print 'Install the following library to make this script work'
print 'Impacket : https://github.com/CoreSecurity/impacket.git'
print 'PyCrypto : https://pypi.python.org/pypi/pycrypto'

這些是前面提到的一些代碼行。

我的問題是這種使用打印的表格是否正確或者我遺漏了一些東西。

那是 Python 2。 Python 3 中最明顯的重大變化是print正確的 function。 Python 2 已棄用; 你現在應該只使用 Python 3 所以應該強制寫

print('Install the following library to make this script work')
print('Impacket : https://github.com/CoreSecurity/impacket.git')
print('PyCrypto : https://pypi.python.org/pypi/pycrypto')

Python 打印語法從 2.x 更改為 3.x。

Python 2.x 語法

print "something"

Python 3.x

print("something")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM