字符转换
时间:2010-01-18 来源:angelia_liu
use String.maketrans() Method to translate some strings.
import string def translate(): intab='abcdefghijklmnopqrstuvwxyz' outtab='cdefghijklmnopqrstuvwxyzab' transtab=string.maketrans(intab,outtab) f=open("E:\\python challenge\\message.txt","r") str=f.read() outStr=string.translate(str,transtab) f2=open("E:\\python challenge\\trans.txt","w") f2.write(outStr) f.close() f2.close() if __name__=='__main__': translate() |
相关阅读 更多 +