新手问题 [已解决] 在.rb 文件中执行 print 函数和 irb 中执行结果不同?

allenfantasy · 2013年12月09日 · 最后由 allenfantasy 回复于 2013年12月09日 · 2638 次阅读

RT。情况如下:

# test.rb
print "gogogo"

在终端中执行 test.rb:

然后我在 irb 里面执行 print 函数:

执行 test.rb 输出的结果多了个百分号?囧 rz……

检查了文件编码,utf-8,除了一行 print 外没有多余代码;ruby 版本是 1.9.3-p448;google 了ruby print 得到的信息大多是 print 和 puts, p 的区别,找不到这个奇怪的现象。求解释……

匿名 #1 2013年12月09日

PS1 好奇怪啊……

只是 zsh 的问题……

When a partial line is preserved, by  default  you  will
see  an inverse+bold character at the end of the partial
line:  a "%" for a normal user or a "#"  for  root.   If
set,  the shell parameter PROMPT_EOL_MARK can be used to
customize how the end of partial lines are shown.

#2 楼 @Kabie 原来是这样……谢谢哇~

需要 登录 后方可回复, 如果你还没有账号请 注册新账号