私は最近、pythonについて教えてきました。これは、str.endswithが最初の引数でタプルを取った例です。私は自分のマシンにPythonの新しいバージョンをインストールしようと決めたので、私はもっと最新のものでした。マシンはCentOS5です。インストール後のCentOSのPython 2.6の問題
マシン上の私のユーザ(ルートではない)として、ここからパッケージを取り出しました:http://www.python.org/ftp/python/2.6.7/、解凍しました。/configure --prefix =/home/myusername/python/compiler/Python-2.6.7-installedその後、makeを実行してテストを行い(すべてOK)、最後にaltinstallを実行してください(私は接頭辞を指定しているのにaltinstallを実行する必要はないはずですが、このマシンで通常のPythonをやめたいとは思わない) 。最初に動作しなかったときには、rootとしてmake altを試してみましたが、違いはありませんでした。ある
./compiler/Python-2.6.7/Lib/test/test_unicode.py : self.assert_(u'asdf' not in '')
./compiler/Python-2.6.7/Lib/test/test_unicode.py : self.assert_('asdf' not in u'')
./compiler/Python-2.6.7/Lib/test/test_unicode.py : self.assert_(u'asdf' not in u'')
./compiler/Python-2.6.7/Lib/test/test_re.py : iter = re.finditer(r".*", "asdf")
./compiler/Python-2.6.7/Lib/test/string_tests.py : self.checkequal(True, 'asdf', '__contains__', 'asdf')
./compiler/Python-2.6.7-installed/lib/python2.6/test/test_unittest.py : loader.loadTestsFromNames(['sdasfasfasdf'])
./compiler/Python-2.6.7-installed/lib/python2.6/test/test_unittest.py : self.assertEqual(str(e), "No module named sdasfasfasdf")
:
私はちょうどこのようなちんぷんかんぷんの束を得るバイナリに対してスクリプトを実行してみてください。これらのような行をたくさんより適宜
./compiler/Python-2.6.7/Lib/test/test_re.pyc : onXtd}|iti|iddddgdS(Nsu" [\u002E\u3002\uFF0E\uFF61]"sa.b.cR$RHRX(R0RÑRÚR RRY(R R7(([email protected]/home/yspendiff/python/compiler/Python-2.6.7/Lib/test/test_re.pyttest_bug_931848as
Cstidd}|i|iid|it|itidd}|i|i id|i|i ddS(Ns\ssa bii(ii(ii(
StopIterationRºRR(R RRÓR tnextRR4t
Rº(([email protected]/home/yspendiff/python/compiler/Python- 2.6.7/Lib/test/test_re.pyttest_bug_581080js
cCsatidd}|i|iid|i|iid|it|idS(Ns.*tasdfii(ii(ii(RRÓR RÝRR4RÞ(R
、おそらく数百のうちのいくつかのランダムなライン。私は、デフォルトのオプションのいずれかを使いこなしたことはありません。面白いバージョンを引っ張ったり、面白いコンパイルオプションを指定したりしています。どのように私はそれをオフにするので、私は平和のコードを書くことができます!
興味のある方は以下のコードをご覧ください。私はちょうど./Findword.pyの空自とそれを呼び出す:あなたがするのPythonを求めている正確に何
#!/home/myusername/python/compiler/Python-2.6.7-installed/bin/python2.6
### FindWord.py
import os # for curdir() #(A)
import os.path # for join(), isfile() #(B)
import sys # for argv[], exit() #(C)
if len(sys.argv) != 2: #(D)
print "need a word or a single-quoted phrase to search for" #(E)
sys.exit(1) #(F)
def searchInFile(pattern, dirname, filenames): #(G)
for name in filenames: #(H)
name = os.path.join(dirname, name) #(I)
if os.path.isfile(name) and not name.endswith(('.pdf','.pl')): #(J)
FH = open(name, 'r') #(K)
for eachline in FH: #(L)
if (eachline.find(pattern) != -1): #(M)
print name, ': ', eachline #(N)
os.path.walk(os.curdir, searchInFile, sys.argv[1]) #(O)
"...冗談の束..." ".... .... pyc'"家に帰る。 –
私は自宅にいる!しかし、ポイントを取って教訓を学んだ。私が指摘したばかげた言葉は、私がそれを実行したときに得ていたPuTTYPuTTYのラインとラインであり、私もそれを投稿していたはずです。 – yoshiwaan