zoukankan      html  css  js  c++  java
  • python implemention javascript encodeURIComponent

    #!/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

  • 相关阅读:
    oo第二次总结
    oo第一次总结
    OO最后一次博客儿
    OO作业总结第三弹
    OO作业总结第二弹
    初学面向对象
    hi🎈
    散列函数及其应用
    结对项目作业
    构建之法第四,第十四章读书有感 (另补第十七章)
  • 原文地址:https://www.cnblogs.com/lexus/p/2405834.html
Copyright © 2011-2022 走看看