字符串转换 能否把 K01,K02,K03,K04 转换成 'K01','K02','K03','K04'(100)

  • 主题发起人 主题发起人 狼崖山
  • 开始时间 开始时间

狼崖山

Unregistered / Unconfirmed
GUEST, unregistred user!
字符串转换 能否把字符串 K01,K02,K03,K04 转换成 'K01','K02','K03','K04'
 
var s:string;begin s:='K01'; s:=''''+s+'''';end;不知道是不是这个意思
 
quotedstr 出来的是 "K01,K02,K03,K04 " 不符合
 
字符串转换 能否把字符串 S=K01,K02,K03,K04 转换成 S='K01','K02','K03','K04'
 
function QuotedStr2(AStr: string): string;var iPos: Integer; TmpStr: string;begin iPos := Pos(',', AStr); if iPos = 0 then Result := AStr else begin while iPos > 0 do begin TmpStr := Copy(AStr, 1, iPos -1); Delete(AStr, 1, iPos); if Result <> '' then Result := Result + ','; Result := Result + QuotedStr(TmpStr); iPos := Pos(',', AStr); end; if AStr <> '' then Result := Result + ',' + QuotedStr(AStr); end;end;
 
var iPos: Integer; TmpStr: string;begin iPos := Pos(',', AStr); if iPos = 0 then Result :=''''+ AStr+'''' else begin while iPos > 0 do begin TmpStr := Copy(AStr, 1, iPos -1); Delete(AStr, 1, iPos); if Result <> '' then Result := Result + ','; Result := Result + QuotedStr(TmpStr); iPos := Pos(',', AStr); end; if AStr <> '' then Result := Result + ',' + QuotedStr(AStr); end;end;
 
后退
顶部