#!/usr/bin/env python
#encoding=utf-8
original=""" !@#$%^&*()-_=+:;."'\/?<>~[]{}`"""
transfer="""%20,!,%40,%23,%24,%25,%5E,%26,*,(,),-,_,%3D,%2B,%3A,%3B,.,%22,',%5C,%2F,%3F,%3C,%3E,~,%5B,%5D,%7B,%7D,%60"""
test="select * from opponent_product"
#select%20*%20from%20opponent_product&key=select%20*%20from%20opponent_product
O=list(original)
print len(O)
T=transfer.split(",")
print O
print T
def gen_mapping(O,T):
dict={}
for o,t in zip(O,T):
dict[o]=t
return dict
print gen_mapping(O,T)
def encodeURIComponent(input):
_input=list(input)
mapping=gen_mapping(O,T)
for index,elem in enumerate(_input):
if elem in mapping:
_input[index]=mapping[elem]
return "".join(_input)
def decodeURIComponent(input):
pass
print len(transfer.split(","))
r=encodeURIComponent(test)
print r
转载于:https://www.cnblogs.com/lexus/archive/2012/03/19/2405834.html