Python 3.x 回复中提到的Twitter bot.ValueError:int()的文本无效,以10为基数:

Python 3.x 回复中提到的Twitter bot.ValueError:int()的文本无效,以10为基数:,python-3.x,tweepy,Python 3.x,Tweepy,那段代码是我写的。我想重播推特上提到的内容。这就是控制台错误所说的: 回溯(最近一次呼叫最后一次): 文件“c:/Users/facun/Desktop/PeroniaDolarHoy/twitterbot.py”,第59行,在 回复推文() 文件“c:/Users/facun/Desktop/PeroniaDolarHoy/twitterbot.py”,第42行,回复tweets last_seen_id=检索_last_seen_id(文件名) 文件“c:/Users/facun/Deskt

那段代码是我写的。我想重播推特上提到的内容。这就是控制台错误所说的: 回溯(最近一次呼叫最后一次): 文件“c:/Users/facun/Desktop/PeroniaDolarHoy/twitterbot.py”,第59行,在 回复推文() 文件“c:/Users/facun/Desktop/PeroniaDolarHoy/twitterbot.py”,第42行,回复tweets last_seen_id=检索_last_seen_id(文件名) 文件“c:/Users/facun/Desktop/PeroniaDolarHoy/twitterbot.py”,第28行,检索最后一次看到的id 上次看到的id=int(f_read.read().strip()) ValueError:基数为10的int()的文本无效:“”


检索上次看到的\u id()
内部,您是否尝试打印
f\u read.read().strip()
import tweepy
import time 
from tweepy import Stream
from tweepy.streaming import StreamListener
import json 
import requests 
from bs4 import BeautifulSoup
import time
FILE_NAME = "last_seen_id.txt"

def retrieve_last_seen_id(file_name):
    f_read = open(file_name,"r")
    last_seen_id = int(f_read.read().strip())
    f_read.close()
    return last_seen_id

def store_last_seen_id(last_seen_id, file_name):
    f_write = open(file_name,"w")
    f_write.write(str(last_seen_id))
    f_write.close()
    return


def reply_to_tweets():
    print ("recogiendo y respondiendo tweets", flush=True)

    last_seen_id = retrieve_last_seen_id(FILE_NAME)

    mentions = api.mentions_timeline(
                               last_seen_id,
                                   tweet_mode="extended")
    for mention in reversed (mentions):
        print(str(mention.id) + "-" + mention.full_text, flush=True)   
        last_seen_id = mention.id
        store_last_seen_id(last_seen_id, FILE_NAME)
        if "dolar hoy" in mention.full_text.lower():
            print("econtramos dolar hoy", flush=True)
            print("respondiendo", flush=True)
            api.update_status("@" + mention.user.screen_name + 
                    "Hola Argentino de bien! Aqui tienes el valor del dolar blue:"+ (preciocompra) + (precioventa))


while True:
    reply_to_tweets()
    time.sleep(15)