python3.6在windows上安装MySQLdb

python要想操作数据库就要

`

import mysqldb

<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">这就要求你要先安装好MySQLdb模块
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">在windows上安装的的流程如下:
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">1、先去下载whl文件
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);"><a href="https://files.pythonhosted.org/packages/f8/d2/d9c6f13eac891d7ff609b7bdf31e5bd05c8f78d841267a9a9ffedfe00bba/mysqlclient-1.3.10-cp36-cp36m-win32.whl" style="margin: 0px; padding: 0px 0px 1px; border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: solid; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(54, 88, 153); border-left-color: initial; border-image: initial; font: inherit; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; text-decoration-line: none; color: rgb(54, 88, 153);">mysqlclient-1.3.10-cp36-cp36m-win32.whl </a>(1.3 MB)
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">或者
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);"><a href="https://files.pythonhosted.org/packages/c8/e0/e38c1fc71355bbc60e89401674bc0190f39a207f0235bb92b7e7b09948d0/mysqlclient-1.3.10-cp36-cp36m-win_amd64.whl" style="margin: 0px; padding: 0px 0px 1px; border-width: 0px 0px 1px; border-top-style: initial; border-right-style: initial; border-bottom-style: solid; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(54, 88, 153); border-left-color: initial; border-image: initial; font: inherit; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; text-decoration-line: none; color: rgb(54, 88, 153);">mysqlclient-1.3.10-cp36-cp36m-win_amd64.whl </a>(1.4 MB)
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">请根据自己的操作系统选择32或者64位的
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);"> 
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">2、将下载的文件放到python中,放到哪个位置?
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">python安装的位置,我安装python的时候走的是默认路径,将下载的文件放大scripts文件夹中即可
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\Scripts
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">接着打开命令行工具开始安装:
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">C:\Users\Administrator>python cd AppData\Local\Programs\Python\Python36-32\Scripts  定位到Scripts文件夹
</p><p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">输入安装命令:
</p><pre class="line-numbers language-python code-toolbar" style="padding: 1em; border: 1px dashed rgb(204, 204, 204); font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 12px; line-height: 1.5; font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; vertical-align: baseline; overflow-wrap: normal; word-break: normal; box-sizing: border-box; text-shadow: white 0px 1px; tab-size: 4; background-color: rgb(245, 242, 240); hyphens: none; overflow: auto; position: relative;">pip install mysqlclient-1.3.10-cp36-cp36m-win32.whlCopy

具体请根据自己的下载文件名称来

接着就安装好了,安装好后验证一下

import MySQLdbCopy

<p style="margin-top: 1em; margin-bottom: 1em; padding: 0px; border: 0px; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-stretch: inherit; font-size: 15px; line-height: 2; font-family: normal, "Avenir Next", Avenir, "Helvetica Neue", Helvetica, "Hiragino Sans GB", 微软雅黑, sans-serif; vertical-align: baseline; overflow-wrap: break-word; word-break: break-all; box-sizing: border-box; color: rgb(30, 30, 30); white-space: normal; background-color: rgb(255, 255, 255);">如果没有报错那就说明安装成功了,就可以进行数据的操作了

王如棋博客
请先登录后发表评论
  • 最新评论
  • 总共0条评论