import\ mysql.connector\n\n#\ Establish\ a\ connection\ to\ the\ MySQL\ server\ncnx\ =\ mysql.connector.connect(user='your_username',\ password='your_password',\n host='your_host',\ database='your_database')\n\n#\ Create\ a\ cursor\ object\ to\ execute\ SQL\ queries\ncursor\ =\ cnx.cursor()\n\n#\ Construct\ the\ SQL\ query\nquery\ =\ "SELECT\ hex(id),\ hex(data)\ FROM\ hash7\ WHERE\ HEX(id)='8df92b4af265ce769a84d47fd7e1ab07'"\n\n#\ Execute\ the\ SQL\ query\ncursor.execute(query)\n\n#\ Fetch\ all\ the\ rows\ returned\ by\ the\ query\nrows\ =\ cursor.fetchall()\n\n#\ Loop\ through\ the\ rows\ and\ print\ the\ values\nfor\ row\ in\ rows:\n print(row[0],\ row[1])\n\n#\ Close\ the\ cursor\ and\ connection\ncursor.close()\ncnx.close()

Python MySQL 查询 HEX 值示例 - 提取数据并转换为十六进制

原文地址: https://www.cveoy.top/t/topic/pPQu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录