import facebook
from datetime import datetime
import time
TIME = datetime.now().strftime
while(1):
STARTINGMIN = 0
STARTINGSEC = 0
STARTINGMIN = TIME("%M")
STARTINGSEC = TIME("%S")
print("Preparing API, Functions, and tokens... Current Time : " + TIME("%H:%M:%S"))
def checklink(link):
links = open("C:\\Users\\BEALL619\\Desktop\\Python\\FACEBOOKPAGEBOT\\usedlinks.txt")
for CHECKING in links.readlines():
CHECKING = CHECKING.rstrip('\n')
print("New link - " + link + " Compared to used link - " + CHECKING)
if str(link) == str(CHECKING):
print("[!] Duplicate link found")
linkstat = "BAD"
break
elif(not link == CHECKING):
print("[*] This is not duplicated... So Far")
print("Link is not duplicated. Preparing to post")
linkstat = "GOOD"
return(linkstat)
"""
cfg = {
"page_id" : "i am not",
"access_token" : "dumb enough to",
"appsecret_proof" : "leave these values in the code"
}
def get_api(cfg):
graph = facebook.GraphAPI(cfg['access_token'])
resp = graph.get_object('me/accounts')
page_access_token = None
for page in resp['data']:
if page['id'] == cfg['page_id']:
page_access_token = page['access_token']
graph = facebook.GraphAPI(page_access_token)
return graph
api = get_api(cfg)
def post(link):
attach = {
"link":link,
}
status = api.put_wall_post(attachment=attach, message = "")
"""
print("Done Preparing API, Functions, And Tokens. Took - " + str(int(TIME("%M")) - int(STARTINGMIN)) + "M " + str(int(TIME("%S")) - int(STARTINGSEC)) + "S")
STARTINGMIN = 0
STARTINGSEC = 0
while(not(TIME("%H") == "00" and TIME("%M") == "00" or TIME("%H") == "02" and TIME("%M") == "00" or TIME("%H") == "04" and TIME("%M") == "00" or TIME("%H") == "06" and TIME("%M") == "00") or TIME("%H") == "08" and TIME("%M") == "00" or TIME("%H") == "10" and TIME("%M") == "00" or TIME("%H") == "12" and TIME("%M") == "00" or TIME("%H") == "14" and TIME("%M") == "00" or TIME("%H") == "16" and TIME("%M") == "00" or TIME("%H") == "18" and TIME("%M") == "00" or TIME("%H") == "20" and TIME("%M") == "00" or TIME("%H") == "22" and TIME("%M") == "00"):
time.sleep(.2)
print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
忽略一切,但问题是..我是一个混乱的程序员(这个脚本还没有完成..显然)
行print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
打印相同的东西......我需要帮助才能正确打印
输入此问题时,我发现问题可能是TIME = datetime.now().strftime
修改
我之所以认为我所做的工作是因为我个人习惯于从变量中调用函数。
在我收到这个问题的帮助之后,我犯的错误是我意外地在变量中存储了一个值,而不是"半个函数"(如果这是有意义的)
答案 0 :(得分:1)
问题是您将now()
存储在变量中,因此无法更新。尝试更改
print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
要:
print("Awaiting Next 2H invertal. Current time is - " + datetime.now().strftime("%H:%M:%S"))
在您想要更新时间的代码中的任何其他位置执行此操作。