編程:空格替換Python

# -*- coding:utf-8 -*-

class Replacement:
def replaceSpace(self, iniString, length):        
   #=================
  # return iniString.replace(" ","%20")

   #================
    i = 0;
    temp = list();
    while i < length:
        c = iniString[i];
        if c == ' ':
            temp.append('%20')
        else:
            temp.append(c)

        i = i + 1;

    return ''.join(temp);
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章