ascii characters switch

ascii = {}

ascii[' '] = ' '
ascii['!'] = '!'
ascii['"'] = '\"'
ascii['#'] = '#'
ascii['$'] = '$'
ascii['%'] = '%'
ascii['&'] = '&'
ascii['''] = '\''
ascii['('] = '('
ascii[')'] = ')'
ascii['*'] = '*'
ascii['+'] = '+'
ascii[','] = ','
ascii['-'] = '-'
ascii['.'] = '.'
ascii['/'] = '/'
ascii['0'] = '0'
ascii['1'] = '1'
ascii['2'] = '2'
ascii['3'] = '3'
ascii['4'] = '4'
ascii['5'] = '5'
ascii['6'] = '6'
ascii['7'] = '7'
ascii['8'] = '8'
ascii['9'] = '9'
ascii[':'] = ':'
ascii['&#59;'] = ';'
ascii['&#60;'] = '<'
ascii['&#61;'] = '='
ascii['&#62;'] = '>'
ascii['&#63;'] = '?'
ascii['&#64;'] = '@'
ascii['&#65;'] = 'A'
ascii['&#66;'] = 'B'
ascii['&#67;'] = 'C'
ascii['&#68;'] = 'D'
ascii['&#69;'] = 'E'
ascii['&#70;'] = 'F'
ascii['&#71;'] = 'G'
ascii['&#72;'] = 'H'
ascii['&#73;'] = 'I'
ascii['&#74;'] = 'J'
ascii['&#75;'] = 'K'
ascii['&#76;'] = 'L'
ascii['&#77;'] = 'M'
ascii['&#78;'] = 'N'
ascii['&#79;'] = 'O'
ascii['&#80;'] = 'P'
ascii['&#81;'] = 'Q'
ascii['&#82;'] = 'R'
ascii['&#83;'] = 'S'
ascii['&#84;'] = 'T'
ascii['&#85;'] = 'U'
ascii['&#86;'] = 'V'
ascii['&#87;'] = 'W'
ascii['&#88;'] = 'X'
ascii['&#89;'] = 'Y'
ascii['&#90;'] = 'Z'
ascii['&#91;'] = '['
ascii['&#92;'] = '\\'
ascii['&#93;'] = ']'
ascii['&#94;'] = '^'
ascii['&#95;'] = '_'
ascii['&#96;'] = '`'
ascii['&#97;'] = 'a'
ascii['&#98;'] = 'b'
ascii['&#99;'] = 'c'
ascii['&#100;'] = 'd'
ascii['&#101;'] = 'e'
ascii['&#102;'] = 'f'
ascii['&#103;'] = 'g'
ascii['&#104;'] = 'h'
ascii['&#105;'] = 'i'
ascii['&#106;'] = 'j'
ascii['&#107;'] = 'k'
ascii['&#108;'] = 'l'
ascii['&#109;'] = 'm'
ascii['&#110;'] = 'n'
ascii['&#111;'] = 'o'
ascii['&#112;'] = 'p'
ascii['&#113;'] = 'q'
ascii['&#114;'] = 'r'
ascii['&#115;'] = 's'
ascii['&#116;'] = 't'
ascii['&#117;'] = 'u'
ascii['&#118;'] = 'v'
ascii['&#119;'] = 'w'
ascii['&#120;'] = 'x'
ascii['&#121;'] = 'y'
ascii['&#122;'] = 'z'
ascii['&#123;'] = '{'
ascii['&#124;'] = '|'
ascii['&#125;'] = '}'
ascii['&#126;'] = '~'

source_str = ''' <s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\"><s:Body><Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:c=\"http://www.w3.org/2001/XMLSchema\"><request xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\"><a:Parameters xmlns:b=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\"><a:KeyValuePairOfstringanyType><b:key>Query</b:key><b:value i:type=\"a" ":FetchExpression\"><a:Query>&#60;fetch aggregate&#61;&#39;true&#39; &#62;&#60;entity name&#61;&#39;postfollow&#39; &#62; &#60;attribute name&#61;&#39;regardingobjectid&#39; aggregate&#61;&#39;countcolumn&#39; alias&#61;&#39;countFollowers&#39; &#47;&#62; &#60;attribute name&#61;&#39;regardingobjecttypecode&#39; groupby&#61;&#39;true&#39; alias&#61;&#39;regarding&#39; &#47;&#62; &#60;attribute name&#61;&#39;regardingobjectid&#39; aggregate&#61;&#39;countcolumn&#39; alias&#61;&#39;" "f3e34a23856443b0b36611e6930629d4&#39; &#47;&#62; &#60;filter type&#61;&#39;and&#39;&#62;&#60;condition attribute&#61;&#39;ownerid&#39; operator&#61;&#39;eq&#39; value&#61;&#39;&#123;95C3F25C-7E84-E411-80BF-005056A80DE8&#125;&#39; &#47;&#62;&#60;condition attribute&#61;&#39;regardingobjectid&#39; operator&#61;&#39;ne&#39; value&#61;&#39;&#123;95C3F25C-7E84-E411-80BF-005056A80DE8&#125;&#39; &#47;&#62; &#60;&#47;filter&#62;&#60;&#47;entity&#62;&#60;&#47;fetch&#62;</a:Query></b:value></a" ":KeyValuePairOfstringanyType></a:Parameters><a:RequestId i:nil=\"true\" /><a:RequestName>RetrieveMultiple</a:RequestName></request></Execute></s:Body></s:Envelope> ''' source_str = source_str.replace('\"\n\t\t\"', '') for k, v in ascii.iteritems(): source_str = source_str.replace(k, v) print source_str

 

posted on 2015-01-12 22:58  keep_walking  阅读(123)  评论(0)    收藏  举报