Skip to content

Instantly share code, notes, and snippets.

@heavenshell
Created December 8, 2011 03:19
Show Gist options
  • Save heavenshell/1445961 to your computer and use it in GitHub Desktop.
Save heavenshell/1445961 to your computer and use it in GitHub Desktop.
Linux(Scientiffic linux):486581715bb2d5d80a7ddef8db81804e
Mac(Snow Leopard):7d1e354a752529921cd202fea2c57c7a
#!/usr/bin/env python
import os
import hashlib
md5hash = hashlib.md5(open(os.path.abspath(__file__), 'rb').read()).hexdigest()
print md5hash
@nobonobo
Copy link

nobonobo commented Dec 8, 2011

Python3では以下のようになるね!

  • open('hoge.txt', 'r').read()は改行コードを正規化した文字列(unicode)を返す。
  • open('hoge.txt', 'rb').read()は読んだままのバイト列を返す。

@heavenshell
Copy link
Author

ありがとうございます!
奥が深いですね。はやく世間が Python3 になって欲しいです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment