python代码:
#!/usr/bin/python
#-*- coding:utf-8 -*-
import os
import sys
import datetime
import re
def isAscii(ch) :
return ch <= u'\u007f'
def formatByWidth(text, width, align_left=True) :
pad = " " * (width - strlen(text))
if align_left :
return text + pad
else :
return pad + text
def strlen(str) :
count = len(str)
for u in str:
if not isAscii(u) :
count += 1