title: How to get rid of square bracket and single quotes when printing in python
body: <p>I can't get to print my dictionary keys without brackets and single quotes. I am a bit stranded here.</p>
  
  <p>I am trying to get data from ldap with the ldap module, getting a list of users and then getting attributes and their values basically. Then I want to print those values in a csv file. </p>
  
  <p>So far the result looks like:</p>
  
  <p>['valueuid'];['valueSN'];['valueGivenname'];['valueo'];;;;</p>
  
  <p>so - I am almost there :-) </p>
  
  <p>this is the code so far ... I have removed some vars.</p>
  
  <pre><code>from __future__ import print_function
  import sys
  import collections
  import ldap
  import ldap.filter
  
  # vars
  countries = ["10", "11", "12", "13", "14"]
  
  # open connection to ldap
  l = ldap.initialize(ldap_server)
  try:
    l.simple_bind_s(username, password)
    #l.protocol_version = ldap.VERSION3
  except ldap.LDAPError, e:
    print(e)
  
  for country in countries:
    # create ldap user list
    searchBase = "ou=employees,l=" + country + ",o=enterprise,dc=acme,dc=com"
    searchScope = ldap.SCOPE_SUBTREE
    searchName = "(uid=*)"
    fieldList = ["uid"]
    user = l.search_s(searchBase, searchScope, searchName, fieldList)
    users = [entry for dn, entry in user if isinstance(entry, dict)]
  
    # Create/Open file for write
    outputfile = open("ava-user_" + country + ".csv","w+")
  
    print("Getting userattributes from Country: ", country)
    print("Writing to file: ava-user_" + country + ".csv")
    print("")
    # print header to file
    print("uid;givenname;sn;o;attrtibute1;attrtibute2;attrtibute3;attrtibute4", file = outputfile)
  
    for user in users:
      # create attribut list for user
      user = ','.join(user['uid'])
      searchBase = "uid=" + user + ",ou=employees,l=" + country + ",o=enterprise,dc=acme,dc=com"
      searchScope = ldap.SCOPE_SUBTREE
      searchName = "(uid=" + user + ")"
      fieldList = ["uid", "givenname", "sn", "o", "attrtibute1", "attrtibute2", "attrtibute3",  "attrtibute4"]
      userattr = l.search_s(searchBase, searchScope, searchName, fieldList)
  
      # remove uid from list
      userattr = [entry for uid, entry in userattr if isinstance(entry, dict)]
  
      # convert userattr from list into a dictionary
      res = {}
      for dicto in userattr:
        res.update(dicto)
        userattr = {}
        userattr = res
  
      # add missing key if it was empty from ldap
      for key in fieldList:
        if key not in userattr.keys():
          userattr[key] = ""
  
      # print userattributes to file
      print('%s;%s;%s;%s;%s;%s;%s;%s' % (userattr['uid'], userattr['givenname'], userattr['sn'], userattr['o'], userattr['attrtibute1'], userattr['attrtibute2'], userattr['attrtibute3'], userattr['attrtibute4']), file = outputfile)
  
    # closing file handle
    outputfile.close()
  
  print("Done")
  
  sys.exit()
  </code></pre>
  
  <p>But the output is supposed to look like ...</p>
  
  <p>valueuid;valueSN;valueGivenname;valueo;;;;</p>
  
  <p>Many Thanks</p>