-#!/usr/bin/python
+#!/usr/bin/python3
#-*-coding: utf8-*-
-import io
import sys
def gen_ent(mail):
- for char in mail:
- ent = "".join(['&#', `ord(char)`, ';'])
- yield ent
+ for char in mail:
+ ent = "".join(['&#', str(ord(char)), ';'])
+ yield ent
def main(inp):
- for mail in inp:
- print mail,":", "".join(gen_ent(mail))
+ for mail in inp:
+ print(mail,":", "".join(gen_ent(mail)))
if __name__ == "__main__":
- if len(sys.argv) == 1:
- inp = []
- for mail in str.split(sys.__stdin__.read()):
- inp.append(mail)
- if len(inp) == 0:
- print "Error: Please use either stdin or $1 for string input!"
- else:
- main(inp)
- else:
- main(sys.argv[1:])
+ if len(sys.argv) == 1:
+ inp = []
+ for mail in str.split(sys.__stdin__.read()):
+ inp.append(mail)
+ if len(inp) == 0:
+ print("Error: Please use either stdin or $1 for string input!",
+ file=sys.stderr)
+ else:
+ main(inp)
+ else:
+ main(sys.argv[1:])