def start(fileName):
开发者_开发问答 fileReader = open(fileName)
for row in fileReader:
print row,
if __name__ == "__main__":
import sys
if len(sys.argv) <= 1:
print "usage quine /path/to/file"
sys.exit(-1)
fileName = sys.argv[0]
start(fileName)
python quine.py foo
No, a quine shouldn't take in any input:
A quine takes no input. Allowing input would permit the source code to be fed to the program via the keyboard, opening the source file of the program, and similar mechanisms.
From Quine (computing).
UPDATE
You need to encode the source into the quine itself. A quine consists of two parts: code that does the actual printing and data that represents the source code. It seems recursive, but isn't really. For a good quine tutorial, I recommend checking out this link; it's what I used to create a quine in a language that I designed.
Quines can't access the filesystem, so no. As Wikipedia states, "Allowing input would permit the source code to be fed to the program via the keyboard, opening the source file of the program, and similar mechanisms.".
Reference: Wikipedia: Quine (computing)
精彩评论