python3 web.py

https://stackoverflow.com/questions/41304192/python-alternative-for-web-py-on-python3

Python3 安装 web.py 失败:

import utils, db, net, wsgi, http, webapi, httpserver, debugerror
    ImportError: No module named 'utils'

按一下办法解决:

pip3 install web.py==0.40.dev0

Python3 安装MySQL
http://www.runoob.com/python3/python3-mysql.html

pip3 install PyMySQL

改错误:
ERROR 1698 (28000): Access denied for user ‘root’@’localhost’

首先查看mysql的conf文件查看用户名和密码:

/etc/mysql

展示如下:

conf.d  debian.cnf  debian-start  my.cnf  my.cnf.fallback  mysql.cnf  mysql.conf.d

执行sudo cat debian.cnf
展示如下:

# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host     = localhost
user     = debian-sys-maint
password = XG6IscrXa4gslb4n
socket   = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host     = localhost
user     = debian-sys-maint
password = XG6IscrXa4gslb4n
socket   = /var/run/mysqld/mysqld.soc

其中user和password即为你的mysql的用户名和密码。再次链接数据库 即可成功!


ERROR (1366, "Incorrect string value: '\\xE6\\x8F\\x8F\\xE8\\xBF\\xB0' for column 'projectDescribe' at row 2")

ERROR (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1.1.0.0\\xe6\\x8f\\x8f\\xe8\\xbf\\xb0'', isUse = 0 WHERE md5 = '339a150f79a8c8d125ad8c' at line 1

ERROR 'latin-1' codec can't encode characters in position 62-63: ordinal not in range(256)

这个错误为,str插入数据库,str有中文参与,需要数据库进行支持,解决办法:

cur.execute("CREATE DATABASE %s default charset utf8 collate utf8_unicode_ci" % operationDB.dbName)

default charset utf8 collate utf8_unicode_ci 至关重要!

其次,每一次连接数据库也需要设置charset:

pymysql.connect("localhost", dbUser, dbPassword, dbName, charset="utf8")

综上即可解决该问题!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值