Generate a random string of 8 characters using Python.
import random 

length = 8
string = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
rand_str = ''.join(random.sample(string,length))

print(rand_str)