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

  • 相关阅读:
    new Handler()和new Handler(Looper.getMainLooper())的区别
    Okhttp3日志采集功能
    【ACM打卡】ZOJ 1001 1048
    20180808 阿里巴巴测试开发工程师一面
    20180601 -1
    20180601
    20180601 指针
    20180601 虚函数
    20180601 C++-1
    20180601 C++
  • 原文地址:https://www.cnblogs.com/lexus/p/2405834.html
Copyright © 2011-2022 走看看