datetime has no attribute now
#You probably have
import datetime
#change that to
from datetime import datetime
datetime has no attribute now
#You probably have
import datetime
#change that to
from datetime import datetime
module 'datetime' has no attribute 'strptime'
Use this: from datetime import datetime
instead of Import datetime
AttributeError: module 'datetime' has no attribute 'timestamp'
import hashlib
import datetime
import timestamp
class Block:
def __init__(self, previous_block_hash, data, timestamp):
self.previous_block_hash = previous_block_hash
self.data = data
self.timestamp = timestamp
self.hash = self.get_hash()
@staticmethod
def create_genesis_block():
return Block("0", "0", datetime.timestamp.now())
def get_hash(self):
header_bin = (str(self.previous_block_hash) +
str(self.data) +
str(self.timestamp)).encode()
inner_hash = hashlib.sha256(header_bin).hexdigest().encode()
outer_hash = hashlib.sha256(inner_hash).hexdigest()
return outer_hash
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us