The following code python2.7 is available.
#encoding =utf8#author:walker#date:2014-09-16#function: Gets the field name of the specified table in the Access file import win32com.clientif __name__ = = ' _ _main__ ': Accesspathfile = R ' D:\tmp\xxx.mdb ' conn = Win32com.client.Dispatch (R ' ADODB. Connection ') DSN = ' provider=microsoft.ace.oledb.12.0;data source= ' + accesspathfile + '; ' Conn. Open (DSN) rs = Win32com.client.Dispatch (R ' ADODB. Recordset ') Rs. CursorLocation = 3tableName = ' xxxx ' sql = ' SELECT TOP 1 * from ' + tablenameprint (SQL) Rs. Open (SQL, conn) for I in range (0, Rs. Fields.Count):p rint (Rs. Fields[i]. Name)
Related reading:
1, Python Operation Access database basic operation steps Analysis
2. ADO gets all the field names of the table
Walker * 2014-09-16 * * *
This article is from "Walker's Journal" blog, please be sure to keep this source http://walkerqt.blog.51cto.com/1310630/1553180
Python Gets Access table field name