我正在构建一个用于练习的 reddit 机器人,将美元转换为其他常用货币,并且我已经设法让转换部分正常工作,但现在我在尝试传递直接跟随美元的字符时有点卡住了签到转换器。
这就是我希望它的工作方式:
def run_bot():
subreddit = r.get_subreddit("randomsubreddit")
comments = subreddit.get_comments(limit=25)
for comment in comments:
comment_text = comment.body
#If comment contains a string that starts with '$'
# Pass the rest of the 'word' to a variable
例如,如果它正在处理这样的评论:
“我花了 5000 美元买了一艘船,太棒了”
它将'5000'分配给一个变量,然后我将通过我的转换器
最好的方法是什么?
(希望这是足够的信息,但如果人们感到困惑,我会添加更多)