tornado web.py 重写tornado.web.RequestHandler 的构造函数

我想在url路由中传递参数,但是不会重写tornado.web.RequestHandler的构造函数,求大神指点。
怎么就收路由里面 AppHandler 传递的“abc”
感恩!

coding: utf-8

import datetime, sys, SocketServer,time
import tornado.httpserver
import tornado.ioloop
from tornado.options import define, options
import tornado.web
import tornado.database
import tornado.escape
import urlparse
import urllib
import re

reload (sys)
sys.setdefaultencoding('utf-8')

class Application(tornado.web.Application):
def init(self):
handlers = [
(r"/abc", AppHandler("abc")),
]
settings = dict(
debug = False,
)
tornado.web.Application.__init__(self, handlers, **settings)

class AppHandler(tornado.web.RequestHandler):
def init(self, *args, **kwargs):
tornado.web.RequestHandler.__init__( self, *args, **kwargs )
self.action=${接收“abc”}

def post(self):
    try:
        self.today = datetime.datetime.today()
        self.did = self.get_argument("did", default = "")


    except:
        pass
    self.set_status(204)
    self.finish()

def get(self):
    try:
        pass
    except Exception, e:
        raise
    else:
        pass
    finally:
        pass

def main(argv):
tornado.options.parse_command_line()
http_server = tornado.httpserver.HTTPServer(Application(), xheaders=True)
http_server.listen(int(argv[1]))
tornado.ioloop.IOLoop.instance().start()
print "start listening..."

if name == "__main__":
main(sys.argv)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
python tornado4.0.2 异步问题
用tornado时,每个请求sleep5秒,异步的方式,但是从浏览器测试没有出现异步的效果,哪位大侠知道呢 class IndexHandler(tornado.web.RequestHandler): @tornado.web.asynchronous @tornado.gen.coroutine def get(self): print("begin") #yield tornado.gen.Task(tornado.ioloop.IOLoop.instance().add_timeout, time.time() + 5) yield gen.Task(IOLoop.instance().add_timeout, IOLoop.instance().time() + 5) ¦ print("after") ¦ greeting = self.get_argument('greeting', 'Hello') ¦ self.write(greeting + ', friendly user!') ¦ self.finish() if __name__ == "__main__": tornado.options.parse_command_line() app = tornado.web.Application(handlers=[(r"/", IndexHandler)]) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start()
在win的VS code上运行tornado项目报路径错误
错误信息: ``` Traceback (most recent call last): File "F:\xvni_hj\tornado_web\lib\site-packages\tornado\web.py", line 1697, in _execute result = method(*self.path_args, **self.path_kwargs) File "F:\xvni_hj\tornado_web\test_web\user\views.py", line 11, in get self.render('index.html') File "F:\xvni_hj\tornado_web\lib\site-packages\tornado\web.py", line 856, in render html = self.render_string(template_name, **kwargs) File "F:\xvni_hj\tornado_web\lib\site-packages\tornado\web.py", line 1002, in render_string t = loader.load(template_name) File "F:\xvni_hj\tornado_web\lib\site-packages\tornado\template.py", line 445, in load self.templates[name] = self._create_template(name) File "F:\xvni_hj\tornado_web\lib\site-packages\tornado\template.py", line 476, in _create_template with open(path, "rb") as f: FileNotFoundError: [Errno 2] No such file or directory: 'F:\\xvni_hj\\tornado_web\\test_web\\user\\templates\\index.html' ``` 文件 : manage.py: ![图片说明](https://img-ask.csdn.net/upload/201904/30/1556590464_701901.png) view.py: ![图片说明](https://img-ask.csdn.net/upload/201904/30/1556590532_168795.png) init.py: ![图片说明](https://img-ask.csdn.net/upload/201904/30/1556590555_515778.png) ![图片说明](https://img-ask.csdn.net/upload/201904/30/1556590579_695180.png) 是只能在Linux下运行吗?
tkinter解释器引用WindRiver Tornado2.2的wtxtcl.dll失败
项目里需要在python下通过TCL解释器引用WindRiver的Tornado2.2安装目录下的wtxtcl.dll来实现对Tornado2.2 基于TCL的控制 python3.4代码如下: ``` import tkinter tcl = tkinter.Tcl() tcl.eval('load d:/applications/tornado2.2/host/x86-win32/bin/wtxtcl.dll wtxtcl') ``` 然后就变成了这样: ![python.exe停止运行](https://img-ask.csdn.net/upload/201511/06/1446776063_275000.png) 但是在tclsh下工作是正常的: ![tclsh正常](https://img-ask.csdn.net/upload/201511/06/1446776176_698787.jpg) tclsh的图中的wtxPath命令是为验证dll引用成功,因为wtxPath是定义在wtxtcl.dll中的命令 求大神帮助
如何在Tornado2.2中实现UDP广播
在Tornado2.2中实现UDP广播,用几个vxsim模拟实现可以么?
Tensorflow测试训练styleGAN时报错 No OpKernel was registered to support Op 'NcclAllReduce' with these attrs.
在测试官方StyleGAN。 运行官方与训练模型pretrained_example.py generate_figures.py 没有问题。GPU工作正常。 运行train.py时报错 尝试只用单个GPU训练时没有报错。 NcclAllReduce应该跟多GPU通信有关,不太了解。 InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'NcclAllReduce' with these attrs. Registered devices: [CPU,GPU], Registered kernels: <no registered kernels> [[Node: TrainD/SumAcrossGPUs/NcclAllReduce = NcclAllReduce[T=DT_FLOAT, num_devices=2, reduction="sum", shared_name="c112", _device="/device:GPU:0"](GPU0/TrainD_grad/gradients/AddN_160)]] 经过多番google 尝试过 重启 conda install keras-gpu 重新安装tensorflow-gpu==1.10.0(跟官方版本保持一致) ``` …… Building TensorFlow graph... Setting up snapshot image grid... Setting up run dir... Training... Traceback (most recent call last): File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1278, in _do_call return fn(*args) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1263, in _run_fn options, feed_dict, fetch_list, target_list, run_metadata) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1350, in _call_tf_sessionrun run_metadata) tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'NcclAllReduce' with these attrs. Registered devices: [CPU,GPU], Registered kernels: <no registered kernels> [[Node: TrainD/SumAcrossGPUs/NcclAllReduce = NcclAllReduce[T=DT_FLOAT, num_devices=2, reduction="sum", shared_name="c112", _device="/device:GPU:0"](GPU0/TrainD_grad/gradients/AddN_160)]] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "train.py", line 191, in <module> main() File "train.py", line 186, in main dnnlib.submit_run(**kwargs) File "E:\MachineLearning\stylegan-master\dnnlib\submission\submit.py", line 290, in submit_run run_wrapper(submit_config) File "E:\MachineLearning\stylegan-master\dnnlib\submission\submit.py", line 242, in run_wrapper util.call_func_by_name(func_name=submit_config.run_func_name, submit_config=submit_config, **submit_config.run_func_kwargs) File "E:\MachineLearning\stylegan-master\dnnlib\util.py", line 257, in call_func_by_name return func_obj(*args, **kwargs) File "E:\MachineLearning\stylegan-master\training\training_loop.py", line 230, in training_loop tflib.run([D_train_op, Gs_update_op], {lod_in: sched.lod, lrate_in: sched.D_lrate, minibatch_in: sched.minibatch}) File "E:\MachineLearning\stylegan-master\dnnlib\tflib\tfutil.py", line 26, in run return tf.get_default_session().run(*args, **kwargs) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 877, in run run_metadata_ptr) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run feed_dict_tensor, options, run_metadata) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1272, in _do_run run_metadata) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\client\session.py", line 1291, in _do_call raise type(e)(node_def, op, message) tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'NcclAllReduce' with these attrs. Registered devices: [CPU,GPU], Registered kernels: <no registered kernels> [[Node: TrainD/SumAcrossGPUs/NcclAllReduce = NcclAllReduce[T=DT_FLOAT, num_devices=2, reduction="sum", shared_name="c112", _device="/device:GPU:0"](GPU0/TrainD_grad/gradients/AddN_160)]] Caused by op 'TrainD/SumAcrossGPUs/NcclAllReduce', defined at: File "train.py", line 191, in <module> main() File "train.py", line 186, in main dnnlib.submit_run(**kwargs) File "E:\MachineLearning\stylegan-master\dnnlib\submission\submit.py", line 290, in submit_run run_wrapper(submit_config) File "E:\MachineLearning\stylegan-master\dnnlib\submission\submit.py", line 242, in run_wrapper util.call_func_by_name(func_name=submit_config.run_func_name, submit_config=submit_config, **submit_config.run_func_kwargs) File "E:\MachineLearning\stylegan-master\dnnlib\util.py", line 257, in call_func_by_name return func_obj(*args, **kwargs) File "E:\MachineLearning\stylegan-master\training\training_loop.py", line 185, in training_loop D_train_op = D_opt.apply_updates() File "E:\MachineLearning\stylegan-master\dnnlib\tflib\optimizer.py", line 135, in apply_updates g = nccl_ops.all_sum(g) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\contrib\nccl\python\ops\nccl_ops.py", line 49, in all_sum return _apply_all_reduce('sum', tensors) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\contrib\nccl\python\ops\nccl_ops.py", line 230, in _apply_all_reduce shared_name=shared_name)) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\contrib\nccl\ops\gen_nccl_ops.py", line 59, in nccl_all_reduce num_devices=num_devices, shared_name=shared_name, name=name) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func return func(*args, **kwargs) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\framework\ops.py", line 3156, in create_op op_def=op_def) File "d:\Users\admin\Anaconda3\envs\tfenv\lib\site-packages\tensorflow\python\framework\ops.py", line 1718, in __init__ self._traceback = tf_stack.extract_stack() InvalidArgumentError (see above for traceback): No OpKernel was registered to support Op 'NcclAllReduce' with these attrs. Registered devices: [CPU,GPU], Registered kernels: <no registered kernels> [[Node: TrainD/SumAcrossGPUs/NcclAllReduce = NcclAllReduce[T=DT_FLOAT, num_devices=2, reduction="sum", shared_name="c112", _device="/device:GPU:0"](GPU0/TrainD_grad/gradients/AddN_160)]] ``` ``` #conda list: # Name Version Build Channel _tflow_select 2.1.0 gpu absl-py 0.8.1 pypi_0 pypi alabaster 0.7.12 py36_0 asn1crypto 1.2.0 py36_0 astor 0.8.0 pypi_0 pypi astroid 2.3.2 py36_0 attrs 19.3.0 py_0 babel 2.7.0 py_0 backcall 0.1.0 py36_0 blas 1.0 mkl bleach 3.1.0 py36_0 ca-certificates 2019.10.16 0 certifi 2019.9.11 py36_0 cffi 1.13.1 py36h7a1dbc1_0 chardet 3.0.4 py36_1003 cloudpickle 1.2.2 py_0 colorama 0.4.1 py36_0 cryptography 2.8 py36h7a1dbc1_0 cudatoolkit 9.0 1 cudnn 7.6.4 cuda9.0_0 decorator 4.4.1 py_0 defusedxml 0.6.0 py_0 django 2.2.7 pypi_0 pypi docutils 0.15.2 py36_0 entrypoints 0.3 py36_0 gast 0.3.2 py_0 grpcio 1.25.0 pypi_0 pypi h5py 2.9.0 py36h5e291fa_0 hdf5 1.10.4 h7ebc959_0 icc_rt 2019.0.0 h0cc432a_1 icu 58.2 ha66f8fd_1 idna 2.8 pypi_0 pypi image 1.5.27 pypi_0 pypi imagesize 1.1.0 py36_0 importlib_metadata 0.23 py36_0 intel-openmp 2019.4 245 ipykernel 5.1.3 py36h39e3cac_0 ipython 7.9.0 py36h39e3cac_0 ipython_genutils 0.2.0 py36h3c5d0ee_0 isort 4.3.21 py36_0 jedi 0.15.1 py36_0 jinja2 2.10.3 py_0 jpeg 9b hb83a4c4_2 jsonschema 3.1.1 py36_0 jupyter_client 5.3.4 py36_0 jupyter_core 4.6.1 py36_0 keras-applications 1.0.8 py_0 keras-base 2.2.4 py36_0 keras-gpu 2.2.4 0 keras-preprocessing 1.1.0 py_1 keyring 18.0.0 py36_0 lazy-object-proxy 1.4.3 py36he774522_0 libpng 1.6.37 h2a8f88b_0 libprotobuf 3.9.2 h7bd577a_0 libsodium 1.0.16 h9d3ae62_0 markdown 3.1.1 py36_0 markupsafe 1.1.1 py36he774522_0 mccabe 0.6.1 py36_1 mistune 0.8.4 py36he774522_0 mkl 2019.4 245 mkl-service 2.3.0 py36hb782905_0 mkl_fft 1.0.15 py36h14836fe_0 mkl_random 1.1.0 py36h675688f_0 more-itertools 7.2.0 py36_0 nbconvert 5.6.1 py36_0 nbformat 4.4.0 py36h3a5bc1b_0 numpy 1.17.3 py36h4ceb530_0 numpy-base 1.17.3 py36hc3f5095_0 numpydoc 0.9.1 py_0 openssl 1.1.1d he774522_3 packaging 19.2 py_0 pandoc 2.2.3.2 0 pandocfilters 1.4.2 py36_1 parso 0.5.1 py_0 pickleshare 0.7.5 py36_0 pillow 6.2.1 pypi_0 pypi pip 19.3.1 py36_0 prompt_toolkit 2.0.10 py_0 protobuf 3.10.0 pypi_0 pypi psutil 5.6.3 py36he774522_0 pycodestyle 2.5.0 py36_0 pycparser 2.19 py36_0 pyflakes 2.1.1 py36_0 pygments 2.4.2 py_0 pylint 2.4.3 py36_0 pyopenssl 19.0.0 py36_0 pyparsing 2.4.2 py_0 pyqt 5.9.2 py36h6538335_2 pyreadline 2.1 py36_1 pyrsistent 0.15.4 py36he774522_0 pysocks 1.7.1 py36_0 python 3.6.9 h5500b2f_0 python-dateutil 2.8.1 py_0 pytz 2019.3 py_0 pywin32 223 py36hfa6e2cd_1 pyyaml 5.1.2 py36he774522_0 pyzmq 18.1.0 py36ha925a31_0 qt 5.9.7 vc14h73c81de_0 qtawesome 0.6.0 py_0 qtconsole 4.5.5 py_0 qtpy 1.9.0 py_0 requests 2.22.0 py36_0 rope 0.14.0 py_0 scipy 1.3.1 py36h29ff71c_0 setuptools 39.1.0 pypi_0 pypi sip 4.19.8 py36h6538335_0 six 1.13.0 pypi_0 pypi snowballstemmer 2.0.0 py_0 sphinx 2.2.1 py_0 sphinxcontrib-applehelp 1.0.1 py_0 sphinxcontrib-devhelp 1.0.1 py_0 sphinxcontrib-htmlhelp 1.0.2 py_0 sphinxcontrib-jsmath 1.0.1 py_0 sphinxcontrib-qthelp 1.0.2 py_0 sphinxcontrib-serializinghtml 1.1.3 py_0 spyder 3.3.6 py36_0 spyder-kernels 0.5.2 py36_0 sqlite 3.30.1 he774522_0 sqlparse 0.3.0 pypi_0 pypi tensorboard 1.10.0 py36he025d50_0 tensorflow 1.10.0 gpu_py36h3514669_0 tensorflow-base 1.10.0 gpu_py36h6e53903_0 tensorflow-gpu 1.10.0 pypi_0 pypi termcolor 1.1.0 pypi_0 pypi testpath 0.4.2 py36_0 tornado 6.0.3 py36he774522_0 traitlets 4.3.3 py36_0 typed-ast 1.4.0 py36he774522_0 urllib3 1.25.6 pypi_0 pypi vc 14.1 h0510ff6_4 vs2015_runtime 14.16.27012 hf0eaf9b_0 wcwidth 0.1.7 py36h3d5aa90_0 webencodings 0.5.1 py36_1 werkzeug 0.16.0 py_0 wheel 0.33.6 py36_0 win_inet_pton 1.1.0 py36_0 wincertstore 0.2 py36h7fe50ca_0 wrapt 1.11.2 py36he774522_0 yaml 0.1.7 hc54c509_2 zeromq 4.3.1 h33f27b4_3 zipp 0.6.0 py_0 zlib 1.2.11 h62dcd97_3 ``` 2*RTX2080Ti driver 4.19.67
python中使用tornado 中post get 请求报错500
我用tornado写了两个接口,第一个没有问题,然后我吧第一个复制到第二个文件里就报错了 第一个接口代码如下: ``` import tornado from wtforms_tornado import Form import sys from app.view.view_xxm.mysqlfuntion import selectnav class hello(tornado.web.RequestHandler): def get(self): self.render("hello.html") class ajaxtest(tornado.web.RequestHandler): def set_default_headers(self): print("setting headers!!!") self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') def get(self): import json type1 = self.get_argument("type") print(type1) data = [{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}] data1 = selectnav(type1) res=dict() res=[ dict( id=k.id, imgurl=k.imgurl, link=k.link, title=k.title, type=k.type, addtime=k.addtime )for k in data1 ] print(res) json = json.dumps(res).encode("utf-8").decode('unicode_escape') self.write(json) # data="你好我是刘德华天涯何处无芳草" # # data.encode("utf-8") # # print("get") # # self.write(data) ``` 第二个接口代码如下 ``` import tornado from wtforms_tornado import Form import sys from app.view.view_xxm.mysqlfuntion import selectnav class hello(tornado.web.RequestHandler): def get(self): self.render("hello.html") class selectnav(tornado.web.RequestHandler): def set_default_headers(self): print("setting headers!!!") self.set_header("Access-Control-Allow-Origin", "*") self.set_header("Access-Control-Allow-Headers", "x-requested-with") self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') def post(self): import json type1 = self.get_argument("type") print(type1) data = [{'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5}] data1 = selectnav(type1) res=dict() res=[ dict( id=k.id, imgurl=k.imgurl, link=k.link, title=k.title, type=k.type, addtime=k.addtime )for k in data1 ] print(res) json = json.dumps(res).encode("utf-8").decode('unicode_escape') self.write(json) # data="你好我是刘德华天涯何处无芳草" # # data.encode("utf-8") # # print("get") # # self.write(data) ``` 报错信息如下: ![图片说明](https://img-ask.csdn.net/upload/201805/17/1526566563_860787.png) 完整代码下载地址 [下载地址](http://test.x-x-mo.com/xxmBackstage.zip "xxmBackstage.zip") 接口路由是ajax和xxm这两个
cmd 运行 pyspider all 时出现如下错误,该怎么解决?
[I 160902 23:03:21 result_worker:49] result_worker starting... Web server running on port 25555 [I 160902 23:03:28 processor:208] processor starting... c:\python27\lib\site-packages\flask\exthook.py:71: ExtDeprecationWarning: Importing flask.ext.login is deprecated, use flask_login instead. .format(x=modname), ExtDeprecationWarning [I 160902 23:03:32 scheduler:569] scheduler starting... [I 160902 23:03:33 scheduler:508] in 5m: new:0,success:0,retry:0,failed:0 Exception in thread Thread-4: Traceback (most recent call last): File "c:\python27\lib\threading.py", line 801, in __bootstrap_inner self.run() File "c:\python27\lib\threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "c:\python27\lib\site-packages\click\core.py", line 534, in invoke return callback(*args, **kwargs) File "c:\python27\lib\site-packages\click\decorators.py", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "c:\python27\lib\site-packages\pyspider\run.py", line 240, in fetcher poolsize=poolsize, proxy=proxy, async=async) File "c:\python27\lib\site-packages\pyspider\fetcher\tornado_fetcher.py", line 85, in __init__ self.ioloop = tornado.ioloop.IOLoop() File "c:\python27\lib\site-packages\tornado\util.py", line 278, in __new__ instance.initialize(*args, **init_kwargs) File "c:\python27\lib\site-packages\tornado\platform\select.py", line 76, in initialize super(SelectIOLoop, self).initialize(impl=_Select(), **kwargs) File "c:\python27\lib\site-packages\tornado\ioloop.py", line 705, in initialize self._waker = Waker() File "c:\python27\lib\site-packages\tornado\platform\common.py", line 44, in __init__ self.writer.connect(connect_address) File "c:\python27\lib\socket.py", line 228, in meth return getattr(self._sock,name)(*args) error: [Errno 10060]
python tornado编程时页面如何连续输出
tornado写服务时,某个请求耗时较长,并且有有持续的输出,在get()中的write()函数只在get()函数执行完之后才会在页面打印相应的内容,如何实现将执行过程中的输出实时的打印出页面? ``` class TestHandler(tornado.web.RequestHandler): def get(self): import time for i in range(10): self.write('this is ime test') time.sleep(1) ``` 我希望的结果是页面上也是每隔一秒打印一次,可实际结果是等10s后页面会一次性显示所有的字符串,求问怎么解决该问题?
tornado motor函数调用另一个异步操作Mongo数据库返回值是Future对象
我用motor在tornado框架下来操作mongodb,按照[官方教学文档](http://motor.readthedocs.org/en/stable/tutorial.html)写的结果正常。 ```python >>> @gen.coroutine ... def do_find_one(): ... document = yield db.test_collection.find_one({'i': {'$lt': 2}}) ... print document ... >>> IOLoop.current().run_sync(do_find_one) {u'i': 0, u'_id': ObjectId('...')} ``` 现在我想实现a.py调用b.py,然后在b.py里面用motor操作mongodb,例如是插入数据,然后返回_id给a.py。我的代码是这样写的: a.py ```python from b import testb from tornado import ioloop from tornado import gen class testa(Object): @gen.coroutine def printa(self): tmp = testb() id = tmp.do_insert() print id a = testa() ioloop.IOLoop.current().run_sync(a.printa) ``` b.py ```python from tornado import gen import motor client = motor.MotorClient('localhost', 27017) db = client.testdb class testb(object): @gen.coroutine def do_insert(self): coll = db.testcoll yield coll.find_one({'bookname': 'huihuang'}) ``` 因为testb加了yield,生成器里面不能用return。我这种写法a.py中print出来的是一个`<tornado.concurrent.Future object at 0x7fa83c900e10>`我不知道怎么获得future里面的数据。 哪位大神帮我看看!或者我哪里理解错了
tornado队列put完后,get方法没有触发
tornado.queues.Queue的队列里put了新的数据,但是没有触发,有人知道为啥吗? @gen.coroutine def sendMsg(self): while 1: logger.info('sendMsg moniter start!') data = yield self.msg_que.get() logger.info('sendMsg moniter rev:%s'%data) try: self.handle_msg(data) except Exception as e: logger.info('sendMsg error:%s' % e) finally: self.msg_que.task_done() 我再rev里加了个断点,发现self.msg_que里是有数据的
tornado 请求相同url阻塞
先贴代码 ``` import time from tornado.gen import coroutine from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.web import Application, RequestHandler class MainHandler(RequestHandler): @coroutine def get(self): client = AsyncHTTPClient() urls = ['http://www.baidu.com'] * 20 start = time.time() yield [client.fetch(url) for url in urls] print(time.time() - start) def make_app(): return Application([(r"/", MainHandler), ]) if __name__ == "__main__": app = make_app() app.listen(8888) IOLoop.current().start() ``` 我通过浏览器访问http://localhost:8888/ ,get方法中请求了相同的链接50次,但是发现所花费的时间是所有请求耗时的总和。百度了发现请求相同的链接会阻塞,但是没找到解决方案。 试了在链接后面加上不同的参数,结果还是阻塞的。 请问各位大佬有解决方案吗?
tornado登陆跳转问题 用ajax提交post请求
用ajax提交post请求后通过验证服务器返回跳转地址,然后又莫名出现了get请求跳回login页面。服务器log如下: ``` [I 170208 15:58:10 web:1971] 200 GET /login (::1) 2.00ms test1 123456 [I 170208 15:58:19 web:1971] 302 POST /login (::1) 3.00ms [I 170208 15:58:19 web:1971] 304 GET / (::1) 2.00ms [I 170208 15:58:19 web:1971] 200 GET /login?_xsrf=2%7Ceaa8943a%7C09432d5ffa3cd4bc80fe8232a2f5e89e%7C1486526704 (::1) 2.00ms ``` 很好奇?_xsrf=27C09432d5ffa3cd4bc80fe8232a2f5e89e%7C148如何添加进去的 index.py ``` #!/usr/bin/env Python # coding=utf-8 import tornado.escape import methods.db as mrd from handlers.base import BaseHandler class LoginHandler(BaseHandler): def get(self): self.render('login.html') def post(self): username = self.get_argument("username") password = self.get_argument("password") print(username,password) user_infos = mrd.select_table(table="users",column="*",condition="username",value=username) if user_infos: db_pwd = user_infos[0][2] if db_pwd == password: self.set_current_user(username) self.redirect("/") else: self.write("2") else: self.write("1") def set_current_user(self, user): print(user) if user: self.set_secure_cookie('user', tornado.escape.json_encode(user))#注意这里使用了 tornado.escape.json_encode() 方法 #print(tornado.escape.json_decode(self.current_user)) else: self.clear_cookie("user") class WelcomeHandler(BaseHandler): @tornado.web.authenticated def get(self): username = tornado.escape.json_decode(self.current_user) self.render('index.html', user=username) print(username) ``` login.html ``` <!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="{{static_url("css/bootstrap.min.css")}}" /> <style> body{ padding: 70px 0; } .pos_m{ margin-top: 10%; margin-bottom: 10%; } </style> </head> <body> <div class="container pos_m"> <div class="row justify-content-center"> <div class="col-lg-3 col-md-5 col-sm-8 "> <form class="form-signin"> {% module xsrf_form_html() %} <h2 class="form-signin-heading">Please sign in</h2> <div class="form-group"> <label for="InputUserName" class="sr-only">username</label> <input type="text" class="form-control form-control-danger" placeholder="Username" id="username"> <label for="InputPassword" class="sr-only">password</label> <input type="password" class="form-control" placeholder="Password" id="password"> </div> <div class="checkbox"> <label> <input type="checkbox"> Remember me </label> </div> <button type="submit" class="btn btn-primary btn-block" id="login">Submit</button> </form> </div> </div> </div> </body> </html> ``` script.js ``` function getCookie(name){ var x = document.cookie.match("\\b" + name + "=([^;]*)\\b"); return x ? x[1]:undefined; } $(document).ready(function(){ $("#login").click(function(){ var user = $("#username").val(); var pwd = $("#password").val(); var pd = {"username":user, "password":pwd, "_xsrf":getCookie("_xsrf")}; $.ajax({ type:"post", url:"/login", data:pd, cache:false, success:function(data){ alert(data); } }); }); }); ``` 菜鸟入门 求大神指教,调试一天了,实在不知道问题在哪里。
tensorflow的InvalidArgumentError报错问题(placeholder)
书上的一个实例,不知道为什么报错。请各位大神帮忙解答一下。 程序如下: from tensorflow.examples.tutorials.mnist import input_data mnist=input_data.read_data_sets("MNIST_data/",one_hot=True) print(mnist.train.images.shape,mnist.train.labels.shape) print(mnist.test.images.shape,mnist.test.labels.shape) print(mnist.validation.images.shape,mnist.validation.labels.shape) import tensorflow as tf sess=tf.InteractiveSession() x=tf.placeholder(tf.float32,[None,784]) W=tf.Variable(tf.zeros([784,10])) b=tf.Variable(tf.zeros([10])) y=tf.nn.softmax(tf.matmul(x,W)+b) y_=tf.placeholder(tf.float32,[None,10]) cross_entropy=tf.reduce_mean(-tf.reduce_sum(y_* tf.log(y),reduction_indices=[1])) train_step=tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy) tf.global_variables_initializer().run() for i in range(1000): batch_xs,batch_ys=mnist.train.next_batch(100) train_step.run({x:batch_xs,y_:batch_ys}) correct_prediction=tf.equal(tf.argmax(y,1),tf.argmax(y_,1)) accuracy=tf.reduce_mean(tf.cast(correct_prediction,tf.float32)) print(accuracy.eval({x:mnist.test.images,y:mnist.test.labels})) 报错如下: runfile('D:/project/Spyder/MNIST_data.py', wdir='D:/project/Spyder') Extracting MNIST_data/train-images-idx3-ubyte.gz Extracting MNIST_data/train-labels-idx1-ubyte.gz Extracting MNIST_data/t10k-images-idx3-ubyte.gz Extracting MNIST_data/t10k-labels-idx1-ubyte.gz (55000, 784) (55000, 10) (10000, 784) (10000, 10) (5000, 784) (5000, 10) D:\soft\Anaconda3\lib\site-packages\tensorflow\python\client\session.py:1645: UserWarning: An interactive session is already active. This can cause out-of-memory errors in some cases. You must explicitly call `InteractiveSession.close()` to release resources held by the other session(s). warnings.warn('An interactive session is already active. This can ' Traceback (most recent call last): File "<ipython-input-2-3b25b2404fa0>", line 1, in <module> runfile('D:/project/Spyder/MNIST_data.py', wdir='D:/project/Spyder') File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "D:/project/Spyder/MNIST_data.py", line 29, in <module> print(accuracy.eval({x:mnist.test.images,y:mnist.test.labels})) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 680, in eval return _eval_using_default_session(self, feed_dict, self.graph, session) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 4951, in _eval_using_default_session return session.run(tensors, feed_dict) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 877, in run run_metadata_ptr) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1100, in _run feed_dict_tensor, options, run_metadata) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1272, in _do_run run_metadata) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1291, in _do_call raise type(e)(node_def, op, message) InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_3' with dtype float and shape [?,10] [[Node: Placeholder_3 = Placeholder[dtype=DT_FLOAT, shape=[?,10], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] [[Node: Mean_3/_29 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_18_Mean_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]] Caused by op 'Placeholder_3', defined at: File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 268, in <module> main() File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 264, in main kernel.start() File "D:\soft\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 478, in start self.io_loop.start() File "D:\soft\Anaconda3\lib\site-packages\zmq\eventloop\ioloop.py", line 177, in start super(ZMQIOLoop, self).start() File "D:\soft\Anaconda3\lib\site-packages\tornado\ioloop.py", line 888, in start handler_func(fd_obj, events) File "D:\soft\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "D:\soft\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events self._handle_recv() File "D:\soft\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv self._run_callback(callback, msg) File "D:\soft\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback callback(*args, **kwargs) File "D:\soft\Anaconda3\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapper return fn(*args, **kwargs) File "D:\soft\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcher return self.dispatch_shell(stream, msg) File "D:\soft\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shell handler(stream, idents, msg) File "D:\soft\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 399, in execute_request user_expressions, allow_stdin) File "D:\soft\Anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 208, in do_execute res = shell.run_cell(code, store_history=store_history, silent=silent) File "D:\soft\Anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 537, in run_cell return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs) File "D:\soft\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2728, in run_cell interactivity=interactivity, compiler=compiler, result=result) File "D:\soft\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2856, in run_ast_nodes if self.run_code(code, result): File "D:\soft\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-2-3b25b2404fa0>", line 1, in <module> runfile('D:/project/Spyder/MNIST_data.py', wdir='D:/project/Spyder') File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "D:\soft\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "D:/project/Spyder/MNIST_data.py", line 20, in <module> y_=tf.placeholder(tf.float32,[None,10]) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1735, in placeholder return gen_array_ops.placeholder(dtype=dtype, shape=shape, name=name) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 5928, in placeholder "Placeholder", dtype=dtype, shape=shape, name=name) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper op_def=op_def) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 454, in new_func return func(*args, **kwargs) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3155, in create_op op_def=op_def) File "D:\soft\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1717, in __init__ self._traceback = tf_stack.extract_stack() InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder_3' with dtype float and shape [?,10] [[Node: Placeholder_3 = Placeholder[dtype=DT_FLOAT, shape=[?,10], _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] [[Node: Mean_3/_29 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_18_Mean_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
tornado _500_error internet server error
在debian上测试tornado框架, >>>python test.py >>>curl http://localhost:8000 之后弹出500错误:internet server error
python pymssql 连接返回错误值为字节集,如何显示为文本。
#源代码:连接返回错误值为字节集,如何显示为文本? ``` import pymssql try: conn = pymssql.connect(server=".\SQLEXPRESS", user="sa", password="1230", database="master",timeout = 0,charset = 'GBK') except Exception as e: print(type(e)) print(dir(e)) print (e) ``` ![图片说明](https://img-ask.csdn.net/upload/202001/16/1579152426_237839.jpg)
为什么在使用catalyst 时候一直有提示错误ImportError: cannot import name 'run_algorithm'?
如题: 以下为我的环境: py 3.6 aiodns==1.1.1 aiohttp==3.5.4 alabaster==0.7.12 alembic==0.9.7 appnope==0.1.0 asn1crypto==0.24.0 astroid==2.2.5 async-timeout==3.0.1 attrdict==2.0.1 attrs==19.1.0 Babel==2.6.0 backcall==0.1.0 bcolz==1.2.1 bleach==3.1.0 boto3==1.5.27 botocore==1.8.50 Bottleneck==1.2.1 cchardet==2.1.1 ccxt==1.17.94 certifi==2019.3.9 cffi==1.12.3 chardet==3.0.4 click==6.7 cloudpickle==1.0.0 contextlib2==0.5.5 cryptography==2.6.1 cycler==0.10.0 cyordereddict==1.0.0 Cython==0.27.3 cytoolz==0.9.0.1 decorator==4.4.0 defusedxml==0.6.0 docutils==0.14 empyrical==0.2.2 enigma-catalyst==0.5.21 entrypoints==0.3 eth-abi==1.3.0 eth-account==0.2.3 eth-hash==0.2.0 eth-keyfile==0.5.1 eth-keys==0.2.2 eth-rlp==0.1.2 eth-typing==2.1.0 eth-utils==1.6.0 hexbytes==0.1.0 idna==2.8 idna-ssl==1.1.0 imagesize==1.1.0 inflection==0.3.1 intervaltree==2.1.0 ipykernel==5.1.0 ipython==7.5.0 ipython-genutils==0.2.0 isort==4.3.19 jedi==0.13.3 Jinja2==2.10.1 jmespath==0.9.4 jsonschema==3.0.1 jupyter-client==5.2.4 jupyter-core==4.4.0 keyring==18.0.0 kiwisolver==1.1.0 lazy-object-proxy==1.4.1 Logbook==0.12.5 lru-dict==1.1.6 lxml==4.3.3 Mako==1.0.7 MarkupSafe==1.1.1 matplotlib==3.1.0 mccabe==0.6.1 mistune==0.8.4 mkl-fft==1.0.12 mkl-random==1.0.2 more-itertools==7.0.0 multidict==4.5.2 multipledispatch==0.4.9 nbconvert==5.5.0 nbformat==4.4.0 networkx==2.1 numexpr==2.6.4 numpy==1.16.0 numpydoc==0.9.1 packaging==19.0 pandas==0.24.2 pandas-datareader==0.6.0 pandocfilters==1.4.2 parsimonious==0.8.1 parso==0.4.0 patsy==0.5.1 pexpect==4.7.0 pickleshare==0.7.5 prompt-toolkit==2.0.9 psutil==5.6.2 ptyprocess==0.6.0 pycares==3.0.0 pycodestyle==2.5.0 pycparser==2.19 pycryptodome==3.8.2 pyflakes==2.1.1 Pygments==2.4.0 pylint==2.3.1 pyOpenSSL==19.0.0 pyparsing==2.4.0 pyrsistent==0.14.11 PySocks==1.7.0 python-dateutil==2.8.0 python-editor==1.0.4 pytz==2019.1 pyzmq==18.0.0 QtAwesome==0.5.7 qtconsole==4.5.1 QtPy==1.7.1 Quandl==3.4.5 redo==2.0.1 requests==2.21.0 requests-file==1.4.3 requests-ftp==0.3.1 requests-toolbelt==0.8.0 rlp==1.1.0 rope==0.14.0 s3transfer==0.1.13 scipy==1.2.1 six==1.12.0 snowballstemmer==1.2.1 sortedcontainers==1.5.9 Sphinx==2.0.1 sphinxcontrib-applehelp==1.0.1 sphinxcontrib-devhelp==1.0.1 sphinxcontrib-htmlhelp==1.0.2 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.2 sphinxcontrib-serializinghtml==1.1.3 spyder==3.3.4 spyder-kernels==0.4.4 SQLAlchemy==1.2.2 statsmodels==0.9.0 tables==3.4.2 testpath==0.4.2 toolz==0.9.0 tornado==6.0.2 traitlets==4.3.2 typed-ast==1.3.4 typing-extensions==3.7.2 urllib3==1.24.3 wcwidth==0.1.7 web3==4.4.1 webencodings==0.5.1 websockets==5.0.1 wrapt==1.11.1 wurlitzer==1.0.2 yarl==1.1.0 在运行catalyst 的时候会提示: runfile('/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency/trading.py', wdir='/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency') Traceback (most recent call last): File "<ipython-input-10-5dde7acc5e52>", line 1, in <module> runfile('/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency/trading.py', wdir='/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency') File "/Users/mac/miniconda3/envs/catalyst/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 827, in runfile execfile(filename, namespace) File "/Users/mac/miniconda3/envs/catalyst/lib/python3.6/site-packages/spyder_kernels/customize/spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency/trading.py", line 6, in <module> from catalyst import run_algorithm File "/Users/mac/Desktop/UPF/Master Thesis/py/crypocurrency/catalyst.py", line 1, in <module> from catalyst import run_algorithm ImportError: cannot import name 'run_algorithm' 我在网上找了很久的解决方案但是都没有一个能解决到的。 会不会是因为在安装catalyst的时候就已经出了这个问题所导致的? 以下为我在安装的时候发生的错误。 请各位大神帮帮忙! ERROR: Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. Note: you may need to restart the kernel to use updated packages.
一个小的python作业系统,看不懂,急求大神指点
主要就是可以发布作业,查看提交作业的系统,是后台的程序 #!/usr/bin/env python # -*- coding: utf-8 -*- import os.path import sys import time import tornado.httpserver import tornado.ioloop import tornado.options import tornado.web from tornado.options import define, options define("port", default=8000, help="run on the given port", type=int) reload(sys) sys.setdefaultencoding('utf-8') DATA = os.path.join(os.path.dirname(__file__), "static", "data.txt") NOW = time.strftime('%Y-%m-%d %X', time.localtime(time.time())) def timecmp(a, b): return (time.strptime(a, '%Y-%m-%d %X') > time.strptime(b, '%Y-%m-%d %X')) with open(DATA, 'r') as fr: data = [line.strip().split(';') for line in fr.readlines()] class IndexHandler(tornado.web.RequestHandler): """docstring for IndexHandler""" def get(self): search = self.get_argument('seclass', "") global data data_filter = [ele for ele in data if ele[1]==search] #compare current time data1 = [i for i in data_filter if not timecmp(NOW, i[3])] data2 = [i for i in data_filter if timecmp(NOW, i[3])] #sort data1=sorted(data1, key=lambda x: time.strptime(x[3], '%Y-%m-%d %X')) data2=sorted(data2, key=lambda x: time.strptime(x[3], '%Y-%m-%d %X'), reverse=True) self.render('yourhomework.html', data1=data1, data2=data2, search=search) def post(self): cname = self.get_argument('classname', "") cnumber = self.get_argument('classnumber', "") detail = self.get_argument('hwdetail', "") year = self.get_argument('year', "") month = self.get_argument('month', "") day = self.get_argument('day', "") hour = self.get_argument('hour', "") if (cname=="" or cnumber=="" or detail=="" or year=="" or month=="" or day=="" or hour==""): self.redirect('/yourhomework.html') else: new_hw = [cname, cnumber, detail, year+"-"+month+"-"+day+" "+hour+":00"] flag = True global data for ele in data: if (ele==new_hw): flag = False if (flag): data.append(new_hw) data_filter = [ele for ele in data if ele[1]==cnumber] data1 = [i for i in data_filter if not timecmp(NOW, i[3])] data2 = [i for i in data_filter if timecmp(NOW, i[3])] data1=sorted(data1, key=lambda x: time.strptime(x[3], '%Y-%m-%d %X')) data2=sorted(data2, key=lambda x: time.strptime(x[3], '%Y-%m-%d %X'), reverse=True) self.render('yourhomework.html', data1=data1, data2=data2, search=cnumber) if __name__ == '__main__': tornado.options.parse_command_line() app = tornado.web.Application( handlers=[(r"/", IndexHandler), (r"/yourhomework.html", IndexHandler)], template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), debug=True ) http_server = tornado.httpserver.HTTPServer(app) http_server.listen(options.port) tornado.ioloop.IOLoop.instance().start() ``` ```
如何创建一个带有指定版本Python和JupyterLab的环境?
&emsp;&emsp;请问要如何在Anaconda中创建一个同时拥有Python 3.7.4与JupyterLab 1.1.4的环境? &emsp;&emsp;我在cmd中通过以下命令创建了一个Python 3.7.4环境: ```batch D:\Anaconda3\envs>conda create -n dp python=3.7 WARNING: A directory already exists at the target location 'D:\Anaconda3\envs\dp' but it is not a conda environment. Continue creating environment (y/[n])? y Collecting package metadata (current_repodata.json): done Solving environment: done ## Package Plan ## environment location: D:\Anaconda3\envs\dp added / updated specs: - python=3.7 The following NEW packages will be INSTALLED: ca-certificates anaconda/pkgs/main/win-64::ca-certificates-2019.8.28-0 certifi anaconda/pkgs/main/win-64::certifi-2019.9.11-py37_0 openssl anaconda/pkgs/main/win-64::openssl-1.1.1d-he774522_2 pip anaconda/pkgs/main/win-64::pip-19.2.3-py37_0 python anaconda/pkgs/main/win-64::python-3.7.4-h5263a28_0 setuptools anaconda/pkgs/main/win-64::setuptools-41.4.0-py37_0 sqlite anaconda/pkgs/main/win-64::sqlite-3.30.0-he774522_0 vc anaconda/pkgs/main/win-64::vc-14.1-h0510ff6_4 vs2015_runtime anaconda/pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_0 wheel anaconda/pkgs/main/win-64::wheel-0.33.6-py37_0 wincertstore anaconda/pkgs/main/win-64::wincertstore-0.2-py37_0 ``` &emsp;&emsp;Python 3.7.4被成功安装,但当继续安装JupyterLab时,会出现以下问题: ```batch D:\Anaconda3\envs>activate dp D:\Anaconda3\envs>conda.bat activate dp (dp) D:\Anaconda3\envs>conda install jupyterlab Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Solving environment: | Found conflicts! Looking for incompatible packages. ... UnsatisfiableError: The following specifications were found to be incompatible with each other: Package tornado conflicts for: jupyterlab -> tornado[version='!=6.0.0,!=6.0.1,!=6.0.2'] Package jinja2 conflicts for: jupyterlab -> jinja2[version='>=2.10'] Package notebook conflicts for: jupyterlab -> notebook[version='>=4.3|>=4.3.1'] Package nodejs conflicts for: jupyterlab -> nodejs[version='<10'] Package sqlite conflicts for: python=3.7 -> sqlite[version='>=3.25.3,<4.0a0|>=3.26.0,<4.0a0|>=3.27.2,<4.0a0|>=3.28.0,<4.0a0|>=3.29.0,<4.0a0'] Package openssl conflicts for: python=3.7 -> openssl[version='>=1.1.1a,<1.1.2a|>=1.1.1b,<1.1.2a|>=1.1.1c,<1.1.2a'] Package pip conflicts for: python=3.7 -> pip Package jupyterlab_launcher conflicts for: jupyterlab -> jupyterlab_launcher[version='>=0.10.0,<0.11.0|>=0.11.0,<0.12.0|>=0.11.2,<0.12.0|>=0.13.1,<0.14.0|>=0.4.0|>=0.6.0,<0.7.0'] Package subprocess32 conflicts for: jupyterlab -> subprocess32 Package futures conflicts for: jupyterlab -> futures Package jupyterlab_server conflicts for: jupyterlab -> jupyterlab_server[version='>=0.2.0,<0.3.0|>=1.0.0,<2.0.0'] Package vc conflicts for: python=3.7 -> vc[version='14.*|>=14.1,<15.0a0'] ``` &emsp;&emsp;这个是什么问题?如何解决?感觉默认的base环境很庞大,很多东西用不到。但想要使用JupyterLab又不得不安装……
python3.8用pyinstaller3.5导不出exe提示TypeError: an integer is required (got type bytes)
我开始以为是我代码出问题, 后来发先即使我的代码是 print ("Hello World!") 都会出现相同的问题 import requests url="https://ar.**d.cn/users/20000" headers = {"Authorization": "Basic NDM1NzY1OTU6ckgyNzdadXpaZi96VUh4b1g3bVZNQkpNMmtUZm5XUjF2ZEdwNWhlVDlDRVlzMjMvV2VBeUJaQWtyR0h2NHcvb1FTTFJjeWNxc1h******UlsS0ZpVEh5TVM5WW96cjR1SURoNkhqSFhLRkNvUWMyZ0kyNUNZTzRXYnM5aUFKRklEMjJXM3lGOE5MeklTYnF0b2g2SXB5QWo0b2FvOUR6KzRHYTlwRGNjamw2S2k3Umw2SUdKZi9Od2ZXSkFsRmJOUnliRzh3T0tZNFEySGpkbHFTSnIxc0pZa0h3TEY4enE4OEt1U3V4TzJzU29j"} r = requests.get(url, headers=headers) print (r.json()) 上面是我之前的代码,测试运行都是没问题的,但是打包exe就出错了 ![图片说明](https://img-ask.csdn.net/upload/201911/07/1573062806_777820.jpg)
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
程序员必须掌握的核心算法有哪些?
由于我之前一直强调数据结构以及算法学习的重要性,所以就有一些读者经常问我,数据结构与算法应该要学习到哪个程度呢?,说实话,这个问题我不知道要怎么回答你,主要取决于你想学习到哪些程度,不过针对这个问题,我稍微总结一下我学过的算法知识点,以及我觉得值得学习的算法。这些算法与数据结构的学习大多数是零散的,并没有一本把他们全部覆盖的书籍。下面是我觉得值得学习的一些算法以及数据结构,当然,我也会整理一些看过...
前端 | 2. 正则
转载请注明以下: 本文转自清自以敬的博客:https://blog.csdn.net/qq_45791147 文章目录1.转义2.正则表达式初步2.1.匹配字符2.1.1.组成元素2.1.2.基础正则的设计 1.转义 转义的作用: 当某个字符在表达式中具有特殊含义,例如字符串引号中出现了引号,为了可以使用这些字符本身,而不是使用其在表达式中的特殊含义,则需要通过转义符“\”来构建该字符转义...
有哪些让程序员受益终生的建议
从业五年多,辗转两个大厂,出过书,创过业,从技术小白成长为基层管理,联合几个业内大牛回答下这个问题,希望能帮到大家,记得帮我点赞哦。 敲黑板!!!读了这篇文章,你将知道如何才能进大厂,如何实现财务自由,如何在工作中游刃有余,这篇文章很长,但绝对是精品,记得帮我点赞哦!!!! 一腔肺腑之言,能看进去多少,就看你自己了!!! 目录: 在校生篇: 为什么要尽量进大厂? 如何选择语言及方...
大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了
大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...
linux系列之常用运维命令整理笔录
本博客记录工作中需要的linux运维命令,大学时候开始接触linux,会一些基本操作,可是都没有整理起来,加上是做开发,不做运维,有些命令忘记了,所以现在整理成博客,当然vi,文件操作等就不介绍了,慢慢积累一些其它拓展的命令,博客不定时更新 free -m 其中:m表示兆,也可以用g,注意都要小写 Men:表示物理内存统计 total:表示物理内存总数(total=used+free) use...
比特币原理详解
一、什么是比特币 比特币是一种电子货币,是一种基于密码学的货币,在2008年11月1日由中本聪发表比特币白皮书,文中提出了一种去中心化的电子记账系统,我们平时的电子现金是银行来记账,因为银行的背后是国家信用。去中心化电子记账系统是参与者共同记账。比特币可以防止主权危机、信用风险。其好处不多做赘述,这一层面介绍的文章很多,本文主要从更深层的技术原理角度进行介绍。 二、问题引入 假设现有4个人...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发...
网页实现一个简单的音乐播放器(大佬别看。(⊙﹏⊙))
今天闲着无事,就想写点东西。然后听了下歌,就打算写个播放器。 于是乎用h5 audio的加上js简单的播放器完工了。 演示地点演示 html代码如下` music 这个年纪 七月的风 音乐 ` 然后就是css`*{ margin: 0; padding: 0; text-decoration: none; list-...
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。
数据库优化 - SQL优化
以实际SQL入手,带你一步一步走上SQL优化之路!
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 cpp 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7 p...
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
《奇巧淫技》系列-python!!每天早上八点自动发送天气预报邮件到QQ邮箱
将代码部署服务器,每日早上定时获取到天气数据,并发送到邮箱。 也可以说是一个小型人工智障。 知识可以运用在不同地方,不一定非是天气预报。
经典算法(5)杨辉三角
杨辉三角 是经典算法,这篇博客对它的算法思想进行了讲解,并有完整的代码实现。
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹...
面试官:你连RESTful都不知道我怎么敢要你?
干货,2019 RESTful最贱实践
Docker 从入门到掉坑
Docker 介绍 简单的对docker进行介绍,可以把它理解为一个应用程序执行的容器。但是docker本身和虚拟机还是有较为明显的出入的。我大致归纳了一下,可以总结为以下几点: docker自身也有着很多的优点,关于它的优点,可以总结为以下几项: 安装docker 从 2017 年 3 月开始 docker 在原来的基础上分为两个分支版本: Docker CE 和 Doc...
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看...
白话阿里巴巴Java开发手册高级篇
不久前,阿里巴巴发布了《阿里巴巴Java开发手册》,总结了阿里巴巴内部实际项目开发过程中开发人员应该遵守的研发流程规范,这些流程规范在一定程度上能够保证最终的项目交付质量,通过在时间中总结模式,并推广给广大开发人员,来避免研发人员在实践中容易犯的错误,确保最终在大规模协作的项目中达成既定目标。 无独有偶,笔者去年在公司里负责升级和制定研发流程、设计模板、设计标准、代码标准等规范,并在实际工作中进行...
SQL-小白最佳入门sql查询一
不要偷偷的查询我的个人资料,即使你再喜欢我,也不要这样,真的不好;
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // doshom...
Nginx 原理和架构
Nginx 是一个免费的,开源的,高性能的 HTTP 服务器和反向代理,以及 IMAP / POP3 代理服务器。Nginx 以其高性能,稳定性,丰富的功能,简单的配置和低资源消耗而闻名。 Nginx 的整体架构 Nginx 里有一个 master 进程和多个 worker 进程。master 进程并不处理网络请求,主要负责调度工作进程:加载配置、启动工作进程及非停升级。worker 进程负责处...
Python 编程开发 实用经验和技巧
Python是一门很灵活的语言,也有很多实用的方法,有时候实现一个功能可以用多种方法实现,我这里总结了一些常用的方法和技巧,包括小数保留指定位小数、判断变量的数据类型、类方法@classmethod、制表符中文对齐、遍历字典、datetime.timedelta的使用等,会持续更新......
YouTube排名第一的励志英文演讲《Dream(梦想)》
Idon’t know what that dream is that you have, I don't care how disappointing it might have been as you've been working toward that dream,but that dream that you’re holding in your mind, that it’s po...
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,...
程序员:我终于知道post和get的区别
是一个老生常谈的话题,然而随着不断的学习,对于以前的认识有很多误区,所以还是需要不断地总结的,学而时习之,不亦说乎
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU...
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员...
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC...
相关热词 c# clr dll c# 如何orm c# 固定大小的字符数组 c#框架设计 c# 删除数据库 c# 中文文字 图片转 c# 成员属性 接口 c#如何将程序封装 16进制负数转换 c# c#练手项目
立即提问