dongqun5769 2011-12-31 16:36
浏览 380
已采纳

用+替换字符串中的所有空格

I have a string and I want to replace every space in this string with a + I tired this by using:

tw.Text = strings.Replace(tw.Text, " ", "+", 1)

But that didn't worked for me...any solutions?

For example the string could look like:

The answer of the universe is 42
  • 写回答

3条回答 默认 最新

  • dony39517 2011-12-31 16:44
    关注

    from the Go documentation: func Replace

    If n < 0, there is no limit on the number of replacements.

    try

    strings.Replace(tw.Text, " ", "+", -1)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 fesafe材料库问题
  • ¥35 beats蓝牙耳机怎么查看日志
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统