from datetime import datetime kini = datetime.now() print kini_jam = kini.hour print kini_menit = kini.minute print kini_detik = kini.second print "{0}:{1}:{2}".format(kini_jam, kini_menit, kini_detik) katanya error di "kini_jam" ???????????
0 jempol
AlGhifari1337
208
4
·
6 tahun, 5 bulan yang lalu
·
1 jempol
Hay coder @Avb apa instruksinya kurang jelas? kamu bisa melihat kode ini. from datetime import datetime kini= datetime.now() n = datetime jam = kini.hour hour = n menit = kini.minute minute = n detik = kini.second second = n print "{}jam:{}menit {}detik".format(jam,menit,detik)
Faalll
87
2
·
6 tahun, 5 bulan yang lalu
·
0 jempol
kalau saya begini gan from datetime import datetime kini = datetime.now() jam = kini.hour menit = kini.minute detik = kini.second print '{}:{}:{}'.format(jam, menit, detik) #semoga membantu
ZihxS
300
816
·
6 tahun, 5 bulan yang lalu
·
1 jempol
Menentukan variabel tidak pakai print, Kode anda : print kini_jam = kini.hour print kini_menit = kini.minute print kini_detik = kini.second harusnya : kini_jam = kini.hour kini_menit = kini.minute kini_detik = kini.second
evaliyanwn
0
0
·
6 tahun, 5 bulan yang lalu
·
0 jempol
def tweetscrap(keyword, timeperiod="today",tweetlimit=500): print("") print("Processing scrap form Twitter...") # Initialize common variable keyword = keyword datadate = str(datetime.now().strftime('%Y-%m-%d')) datatime = str(datetime.now().strftime('%H:%M:%S')) idsearch = str(datetime.now().strftime('%Y%m%d'))+str(datetime.now().strftime('%H%M%S')) lang = 'in' if tweetlimit=='': tweetlimit = int(500) else: tweetlimit = int(tweetlimit) # Get date range of the query datebegin, dateend = getdaterange(timeperiod) # Write data in json numdata = 0 print(datebegin) print(dateend) # query, limit=None, begindate=dt.date(2017,1,1), enddate=dt.date.today(), poolsize=20, lang='' for tweet in query_tweets(keyword, tweetlimit, datebegin, dateend, 20, lang): #10000 = 500 fullname = tweet.fullname.encode('utf-8') idtweet = tweet.id.encode('utf-8') likes = tweet.likes.encode('utf-8') replies = tweet.replies.encode('utf-8') retweets = tweet.retweets.encode('utf-8') text = tweet.text.encode('utf-8') timestamp = str(tweet.timestamp) user = tweet.user.encode('utf-8') # Make json form form = { "created_at": timestamp, "id": idtweet, "user":{ "name": fullname, "screen_name":user, "followers_count": None, "friends_count": None }, "text": text, "coordinates": None, "favorite_count": likes, "reply_count": replies, "retweet_count": retweets, "lang": lang} # Write the form to json file with open('datascrap/'+idsearch+'.json', 'a') as outfile: json.dump(form, outfile) outfile.write('\n') outfile.close() # Count the number of data processed numdata += 1 # Ask hardware to sleep for 5 second time.sleep(5) respone = ({ 'keyword' : keyword, 'datadate' : datadate, 'datatime' : datatime, 'file_name' : idsearch }) return respone Ini kenapa hasil jumlah data yang diminta sama hasil scarappingnya beda jauh banget ya? kalo minta data 400 itu cuma bisa dapat hasil sekitar 20an apa ada yang bisa bantu jelaskan ini kenapa? terimakasih sekali