You can use list () with an empty prefix (first parameter) and a folder separator (second parameter) to achieve what you are asking for:
s3conn = boto.connect_s3(access_key, secret_key, security_token=token)
bucket = s3conn.get_bucket(bucket_name)
folders = bucket.list('', '/')
for folder in folders:
print folder.name
Note:
There is no such thing as “folders” in S3. All you have is buckets and objects.
. : name-of-folder/name-of-file, , : name-of-file, : name-of-folder - , "".
AWS CLI ( ): s3ls <bucket-name> "" .