# -*- coding:UTF-8 -*-
#!/usr/bin/python

import os
import sys

def myPrint():
   if len(sys.argv) < 2:
      print('沒有輸入檔名！')
      return
   fn = os.path.join(sys.path[0], sys.argv[1])
   try:
      f = open(fn, 'r')
      line = f.readline()
      print('Ansi:')
   except FileNotFoundError:
      print('找不到', fn)
      return
   except UnicodeDecodeError:
      import codecs
      f = codecs.open(fn, 'r', 'utf-8')
      line = f.readline()
      print('Utf-8:')

   while line:
      print(line)
      line = f.readline()
   f.close()

myPrint()

input('Press enter to continue......')
