Crypto developer focused on Java, Python, JavaScript, Verilog, etc.
Official website:
小白的Python入门教程实战篇:网站+iOS App源码→ http://t.cn/R2PDyWN 赞助→ http://t.cn/R5bhVpf
License: GNU General Public License v3.0
Crypto developer focused on Java, Python, JavaScript, Verilog, etc.
Official website:
报错:
Traceback (most recent call last):
File "E:/pyproject/awesome-python3/123.py", line 13, in
loop.run_until_complete(test(loop))
File "D:\soft\python3.6\lib\asyncio\base_events.py", line 467, in run_until_complete
return future.result()
File "E:/pyproject/awesome-python3/123.py", line 10, in test
await u.save()
File "E:\pyproject\awesome-python3\orm.py", line 190, in save
rows = await execute(self.insert, args)
File "E:\pyproject\awesome-python3\orm.py", line 54, in execute
await cur.execute(sql.replace('?', '%s'), args)
File "D:\soft\python3.6\lib\site-packages\aiomysql\cursors.py", line 239, in execute
yield from self._query(query)
File "D:\soft\python3.6\lib\site-packages\aiomysql\cursors.py", line 460, in _query
yield from conn.query(q)
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 398, in query
yield from self._read_query_result(unbuffered=unbuffered)
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 582, in _read_query_result
yield from result.read()
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 835, in read
first_packet = yield from self.connection._read_packet()
File "D:\soft\python3.6\lib\site-packages\aiomysql\connection.py", line 552, in _read_packet
packet.check_error()
File "D:\soft\python3.6\lib\site-packages\pymysql\connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "D:\soft\python3.6\lib\site-packages\pymysql\err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (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 '.NULL.NULL.1504753670.12085.'00150475367012054e14a83e18b4803a3a2d839acba2587000'' at line 1")
awesome-python3-webapp/www/handlers.py
Line 82 in ab1592b
感谢您的 python 教程@michaelliao。 有个疑问:
orm模块中 Model 类中定义了 findNumber() 方法。
里面的的这句 SQL:
"select %s num from %s
"
其中 num 没有看懂。。。
我是不是错过了啥?
在post中携带参数,例如http://127.0.0.1:9000?test=123
这种类型如何处理???
Day 03 中抛出错误时,使用了 StandardError
,在 python3 中推荐使用 Exception
代替。
在第10天里边的注册问题
wwww/static里边的文件都是从git下载的,html文件也都没有问题。
在点击完注册按钮后,页面没有反应,
浏览器的地址从
http://127.0.0.1:9000/register
变成了
http://127.0.0.1:9000/register?
数据库里也没有写入新的数据。
也看了原贴下边的一些讨论,没有看到有效的解决方法,特此前来 求教
The problem is as follow:
pymysql.err.ProgrammingError: (1146, "Table 'awesome.blogs' doesn't exist")
I wonder when can I find the contest of the awesome.blogs?
Hopefully for help and best wishes.
报错:
pymysql.err.ProgrammingError: (1146, "Table 'awesome.blogs' doesn't exist")
awesome.blogs 的内容是什么,在哪可以找到,求教!
Traceback (most recent call last):
File "/Users/liulizhong/awesome-python3-webapp/www/test.py", line 15, in
loop.run_until_complete(insert(loop))
File "/anaconda3/lib/python3.6/asyncio/base_events.py", line 473, in run_until_complete
return future.result()
File "/Users/liulizhong/awesome-python3-webapp/www/test.py", line 11, in insert
await u.save()
File "/Users/liulizhong/awesome-python3-webapp/www/orm.py", line 233, in save
rows = await execute(self.insert,args)
File "/Users/liulizhong/awesome-python3-webapp/www/orm.py", line 48, in execute
await cur.execute(sql.replace('?', '%s'), args)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/cursors.py", line 237, in execute
await self._query(query)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/cursors.py", line 455, in _query
await conn.query(q)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 420, in query
await self._read_query_result(unbuffered=unbuffered)
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 607, in _read_query_result
await result.read()
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 1089, in read
first_packet = await self.connection._read_packet()
File "/anaconda3/lib/python3.6/site-packages/aiomysql/connection.py", line 578, in _read_packet
packet.check_error()
File "/anaconda3/lib/python3.6/site-packages/pymysql/protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "/anaconda3/lib/python3.6/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
pymysql.err.ProgrammingError: (1146, "Table 'awesome.user' doesn't exist")
源码是
import orm , asyncio
from models import User, Blog, Comment
async def insert(loop):
await orm.create_pool(loop = loop, user='liusanshui', password='12345', db='awesome')
u = User(name='Test', email='[email protected]', passwd='1234567890', image='about:blank')
await u.save()
loop = asyncio.get_event_loop()
loop.run_until_complete(insert(loop))
loop.run_forever()
for x in insert(loop):
pass
有没有大牛能帮忙看一下
C-Shopping-RN APP
This is a complete App developed by React Native (Expo). It is a beautiful e-commerce shopping application.
App open source address: https://github.com/huanghanzhilian/c-shopping-rn
Full stack open source address: https://github.com/huanghanzhilian/c-shopping
when i click the delete button, i find that cannot delete blogs. Is there missing some function?
fab build
[60.205.190.223] Executing task 'build'
[localhost] local: rm -f dist/dist-awesome.tar.gz
[localhost] local: tar --dereference -czvf ../dist/dist-awesome.tar.gz --exclude='test' --exclude='.*' --exclude='*.pyc' --exclude='*.pyo' static templates transwarp favicon.ico *.py
tar: Failed to open '../dist/dist-awesome.tar.gz'
Fatal error: local() encountered an error (return code 1) while executing 'tar --dereference -czvf ../dist/dist-awesome.tar.gz --exclude='test' --exclude='.*' --exclude='*.pyc' --exclude='*.pyo' static templates transwarp favicon.ico *.py'
Aborting.
希望博主能在百忙中抽空帮我解答下,我用博主的github clone 下来运行也是这样
Traceback (most recent call last):
File "app.py", line 154, in
loop.run_until_complete(init(loop))
File "/usr/local/python3/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "app.py", line 142, in init
yield from orm.create_pool(loop=loop, **configs.db)
File "/home/wwwroot/LNMP/python_web/www/orm.py", line 20, in create_pool
user=kw['awesome_user'],
KeyError: 'awesome_user'
FFFFFF
找了好久,还是没发现原因,求指点一下
详细代码项目:https://github.com/Mr1yan/awesome-python3-webapp
详细信息:
INFO:root:create database connection pool...
INFO:root:init jinja2...
INFO:root:set jinja2 template path: E:\Python\awesome-python3-webapp\www\templates
INFO:root:found model: User (table: users)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: email ==> <StringField, varchar(50):None>
INFO:root: found mapping: passwd ==> <StringField, varchar(50):None>
INFO:root: found mapping: admin ==> <BooleanField, boolean:None>
INFO:root: found mapping: name ==> <StringField, varchar(50):None>
INFO:root: found mapping: image ==> <StringField, varchar(500):None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:found model: Blog (table: blogs)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_name ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_image ==> <StringField, varchar(500):None>
INFO:root: found mapping: name ==> <StringField, varchar(50):None>
INFO:root: found mapping: summary ==> <StringField, varchar(200):None>
INFO:root: found mapping: content ==> <TextField, text:None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:found model: Comment (table: comments)
INFO:root: found mapping: id ==> <StringField, varchar(50):None>
INFO:root: found mapping: blog_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_id ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_name ==> <StringField, varchar(50):None>
INFO:root: found mapping: user_image ==> <StringField, varchar(500):None>
INFO:root: found mapping: content ==> <TextField, text:None>
INFO:root: found mapping: created_at ==> <FloatField, real:None>
INFO:root:add route GET / => index(request)
INFO:root:add static /static/ => E:\Python\awesome-python3-webapp\www\static
INFO:root:server started at http://127.0.01:9000...
INFO:root:Request:GET /
INFO:root:Response handler...
INFO:root:call with args:{'request': <Request GET / >}
INFO:root:SQL: select id
, email
, passwd
, admin
, name
, image
, created_at
from users
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web_protocol.py", line 421, in start
resp = yield from self._request_handler(request)
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web.py", line 303, in _handle
resp = yield from handler(request)
File "E:/Python/awesome-python3-webapp/www/app.py", line 46, in logger
return (await handler(request))
File "E:/Python/awesome-python3-webapp/www/app.py", line 64, in response
r=await handler(request)
File "E:\Python\Python36-32\lib\site-packages\aiohttp\web_urldispatcher.py", line 113, in handler_wrapper
result = yield from result
File "E:\Python\awesome-python3-webapp\www\coreweb.py", line 138, in call
r=await self._func(**kw)
File "E:\Python\Python36-32\lib\asyncio\coroutines.py", line 223, in coro
res = yield from await_meth()
File "E:\Python\awesome-python3-webapp\www\handlers1.py", line 13, in index
users=await User.findAll()
File "E:\Python\awesome-python3-webapp\www\orm.py", line 188, in findAll
rs = await select(' '.join(sql), args)
File "E:\Python\awesome-python3-webapp\www\orm.py", line 32, in select
async with __pool.get() as conn:
NameError: name '__pool' is not defined
INFO:aiohttp.access:127.0.0.1 - - [10/Jul/2017:16:47:31 +0000] "GET / HTTP/1.1" 500 330 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"
in app.py line 95 't' should be correct to 'r'
python 版本 Python 3.7.3
vscode 中显示 orm.py 报错: Undefined variable 'StandardError'
class ModelMetaclass(type):
def __new__(cls, name, bases, attrs):
if name=='Model':
return type.__new__(cls, name, bases, attrs)
tableName = attrs.get('__table__', None) or name
logging.info('found model: %s (table: %s)' % (name, tableName))
mappings = dict()
fields = []
primaryKey = None
for k, v in attrs.items():
if isinstance(v, Field):
logging.info(' found mapping: %s ==> %s' % (k, v))
mappings[k] = v
if v.primary_key:
# 找到主键:
if primaryKey:
raise StandardError('Duplicate primary key for field: %s' % k)
stackoverflow 中有个回答, "exception StandardError which was removed in Python 3.",是这样的吗?
in orm.py file, and in line 22.
db=kw['db']
should change to
db = kw['database']
since in config_default.py , you defines
configs = { 'debug': True, 'db': { 'host': '123.206.28.72', 'port': 3306, 'user': 'root', 'password': '12345', 'database': 'awesome' }, 'session': { 'secret': 'AwEsOmE' } }
I runned through the code.
我按照廖老师的教程,想注册一个用户名后点击提交有错误,希望帮我解决一下:
点击后页面出现:网络好像出问题了 (HTTP 500)
INFO:root:server started at http://127.0.0.1:9000...
INFO:root:Request: GET /register
INFO:root:Response handler...
INFO:root:call with args: {}
INFO:aiohttp.access:127.0.0.1 - - [14/Dec/2017:07:54:29 +0000] "GET /register HTTP/1.1" 200 6587 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8"
INFO:root:Request: POST /api/users
INFO:root:Response handler...
INFO:root:call with args: {'email': '[email protected]', 'name': 'ka', 'passwd': '4ff03fb6437edad36af5fd180c42ec483983c1fc'}
/Users/k.den/awesome-python3-webapp/www/handlers.py:132: RuntimeWarning: coroutine 'Model.findAll' was never awaited
users = yield from User.findAll('email=?', [email])
ERROR:aiohttp.server:Error handling request
Traceback (most recent call last):
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 417, in start
resp = yield from self._request_handler(request)
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web.py", line 289, in _handle
resp = yield from handler(request)
File "app.py", line 43, in logger
return (await handler(request))
File "app.py", line 61, in response
r = await handler(request)
File "/anaconda3/lib/python3.6/site-packages/aiohttp/web_urldispatcher.py", line 111, in handler_wrapper
result = yield from result
File "/Users/den/awesome-python3-webapp/www/coroweb.py", line 138, in call
r = yield from self._func(**kw)
File "/anaconda3/lib/python3.6/asyncio/coroutines.py", line 213, in coro
res = yield from res
File "/Users/den/awesome-python3-webapp/www/handlers.py", line 132, in api_register_user
users = yield from User.findAll('email=?', [email])
TypeError: cannot 'yield from' a coroutine object in a non-coroutine generator
Traceback (most recent call last):
File "E:\Anaconda3\lib\site-packages\aiohttp\web_protocol.py", line 410, in st
art
resp = yield from self._request_handler(request)
File "E:\Anaconda3\lib\site-packages\aiohttp\web.py", line 325, in _handle
resp = yield from handler(request)
File "E:\Anaconda3\lib\site-packages\aiohttp\web_middlewares.py", line 93, in
impl
return (yield from handler(request))
File "app.py", line 61, in logger
return (yield from handler(request))
File "app.py", line 100, in auth
return (yield from handler(request))
File "app.py", line 120, in response
r = yield from handler(request)
File "E:\Anaconda3\lib\site-packages\aiohttp\web_urldispatcher.py", line 142,
in handler_wrapper
result = yield from result
File "G:\0pythonstudy\chengxu\webAPP python廖雪峰\PureBlog-master\www\web_fram
e.py", line 200, in __call__
return web.HTTPBadRequest('Missing argument: %s' % name)
TypeError: __init__() takes 1 positional argument but 2 were given
这是什么情况,求赐教!
照着test.html敲进去或者直接copy test.html一直报jinja2.exceptions.TemplateSyntaxError: unexpected '}'
我的test.html如下,看着模版文件写的语法没问题呀
<title>Test users - Awesome Python Webapp</title>{{ u.name }} / {{ u.email }}
{% endfor %}async def execute(sql, args, autocommit = True):
....
async with __pool.get() as conn:
...
try:
async with conn.cursor(aiomysql.DictCursor) as cur:
await cur.execute(sql.replace('?','%s'),args)
affected = cur.rowcount
....
except BaseException:
.....
return affected
在这个代码里面 cur.execute(sql.replace('?','%s'),args)
如果执行错误的话(例如重复插入unique key相同的数据),下面的local variable affected 变量不会被申明且赋值,而在try外面 affected 又被返回,此时会报错,且在调用excute函数的外面并没有捕获异常导致程序崩溃.
clone工程变切换branch到day4运行以下测试代码
`
import orm
from models import User, Blog, Comment
def test():
yield from orm.create_pool(user='www-data', password='www-data', database='awesome')
u = User(name='Test', email='[email protected]', passwd='1234567890', image='about:blank')
yield from u.save()
for x in test():
pass
出现了这个错误在windows上,python3.6.2
$ python test_model.py
Traceback (most recent call last):
File "test_model.py", line 1, in
import orm
File "C:\Users\Administrator\Desktop\github\awesome-python3-webapp\www\orm.py", line 16
__pool = yield from aiomysql.create_pool(
^
SyntaxError: 'yield from' inside async function
`
查了2天资料没找到问题出在哪,不知道是不是python版本的问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.