내가 임의의 숫자에 의해 문자열의 문자를 대체 할 코드의 조각을 실행하기 위해 노력하고있어 golang이 실행golang 번호로 교체 문자열 문자
//Get the position between 0 and the length of the string-1 to insert a random number
position := rand.Intn(count - 1)
strings.Replace(RandomString,)
fmt.Println("Going to change the position number: ", position)
//Insert a random number between [0-9] in the position
RandomString = RandomString[:position] + string(rand.Intn(9)) + RandomString[position+1:]
, 출력은 다음과 같습니다
I was going to generate.. ljFsrPaUvmxZFFw
Going to change the position number: 2
Random string: lsrPaUvmxZFFw
누구든지 원하는 문자열 위치에 해당 번호를 삽입하는 데 도움이 될 수 있습니까? 나는 이것에 대한 중복 사례를 찾지 못했습니다.
미리 감사드립니다.
사용하고 싶습니다. – RayfenWindspear
완료. 어떻게 그걸 기억하지 못했을까요? : facepalm : –
뒤에서 '문자열'은 단지 [[] 바이트 '라는 것을 기억하십시오. 'int'를'string'으로 형변환하려고 시도했을 때, 원시 번호 인'2' (문자가 아닙니다)를 유니 코드로 표시하려했습니다. – RayfenWindspear