我将尝试消除打印出来的方括号
我的代码如下:
我希望输出结果看起来像
[]
和换行符 \n
。我的代码如下:
name1 = File.readlines('first.txt').sample(1)
name2 = File.readlines('middle.txt').sample(1)
name3 = File.readlines('last.txt').sample(1)
name = print (name1.strip
print name2.strip
print name3.strip)
puts name
我希望输出结果看起来像
JoshBobbyGreen
。
然而,它看起来像:[\"Josh\\n\"][\"Bobby\\n\"][\"Green\\n\"]
我尝试使用 .gsub
、chomp
和 split
,但可能我使用方法不正确。
fullname.rb:36:in
strip': wrong number of arguments (1 for 0) (ArgumentError) from yahoo.rb:36:in<main>'
- marriedjane875