0
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"))
不顧一切,但問題的strftime不會裏面更新..我凌亂的程序員(這個劇本不這樣做又.. obvisouly)datetime.now()。while循環
行print("Awaiting Next 2H invertal. Current time is - " + TIME("%H:%M:%S"))
打印同樣的事情...我需要用它打印正確
同時鍵入這個問題,我知道無助於問題可能是TIME = datetime.now().strftime
編輯
我之所以認爲我所做的工作是因爲我個人習慣於從變量調用函數。
我從這個問題我所犯的錯誤是我不小心存放在變量,而不是「半函數值」得到的幫助後(如果是有道理的)
內環路你在哪裏試圖更新時間 –
我想我知道你在暗示什麼.. 我應該只是datetime.now更換時間無處不在的代碼()。STRFTIME – Beall619
所以我想不會,監守你想每次通過循環檢入一次,而不是繼續打勾。可能有意義的是,在循環外部設置startTime並使用它來設置起始值,然後取出TIME = statemnent並將其設置爲while循環內的第一行。 –