[英]how can i use ruby and twitter tweet from text file
我正在嘗試從文本文件中發送推文而沒有獲得額外的符號。
我的推文看起來像:[“這是我在 twitter 上的推文示例”\\n] << 它包括符號和額外的“n”。
我想要得到的是:這是我希望我的推文看起來像什么的示例。 << 沒有額外的符號。
我的代碼:
def tweet
file = File.open("tweets_from.txt","r")
read = file.readlines.sample(1)
client.update("#{read}").text
end
tweet
在此先感謝您的幫助 :)
read = file.readlines.map(&:chomp).sample
client.update(read).text
只要改變就足夠了
read = file.readlines.sample(1)
對此:
read = file.readlines.sample.chomp
有關此方法的更多信息(以及許多其他方法!),請訪問: Ruby String docs
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.