-
0 votesanswersviews
使用Stream线程和2个Popen进程安全地退出python3脚本
我的脚本执行以下操作: 打开一个串口并从中读取信息 将上述信息传递给另一个二进制文件,以json格式提供信息 我使用 ReaderThread 类继承 threading.Thread 接收流以提供非阻塞实现 代码细分 我创建了两个进程来执行 actisense -r /dev/ttyUSB0 | analyzer -json actisense_process = Popen(['a... -
0 votesanswersviews
Opencv Python-3.5.2人脸识别
我正致力于面部识别 . 我的代码工作正常,但结果不是很好,所以我做了一些修改,再加上一些修改,我更新了我的 opencv-python from 3.4.3 to 3.4.4 和 opencv-contrib-python 相同 . 现在我收到了语法错误 . img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) Error: cv2.error: Op... -
0 votesanswersviews
UnicodeEncodeError:'charmap' codec can 't encode character ' \ u2014'Python Beautiful Soup
这是我的代码: soup = bs4.BeautifulSoup(res.text, "html.parser") linkElems = soup.select('.r a') for i in range(len(linkElems)): t = linkElems[i].findAll(text=True) print(t) 这给了我错误: 回溯(最... -
0 votesanswersviews
为什么我无法导入google-cloud-speech?
我已经安装了谷歌SDK,似乎响应相当不错 . 我还下载了google-cloud-speech,用于语音转换 . 但是,当我尝试导入google.cloud时,我在IDE(Pycharm)中看不到任何关于“ Cloud ”的建议 . 我试图通过2种方式重新安装库,使用PIP和Pycharm中的另一种方式 . 他们似乎都没有工作 . 要验证我已检查已安装库的路径,并且令人惊讶地存在于那里 . 以下是... -
2 votesanswersviews
Tensorflow没有在jupyter笔记本中的GPU上运行
在Ubuntu上为GTX 1080 ti成功安装了Cuda和cudnn,在jupyter笔记本中运行一个简单的TF程序,在运行tensorflow-gpu == 1.0 vs tensorflow == 1.0的conda环境中速度不会增加 . 当我运行nvidia-smi时: +-----------------------------------------------------------... -
0 votesanswersviews
我的picam到raspberry pi 3进行人脸检测,但我收到此错误
gray = cv2.cvtColor(image_frame,cv2.COLOR_BGR2GRAY)cv2.error:/home/pi/Downloads/opencv/modules/imgproc/src/color.cpp:11095:error:( - 1515)scn == 3 || scn == 4在函数cvtColor中 . 无论如何解决它而不改变picam? # Impor... -
0 votesanswersviews
Python AttributeError:'str' object没有属性'get_price'
我试图从main.py获取用户输入,然后将输出定制到所述用户输入 . 我不仅得到了这个错误,而且当我启动main.py时,似乎我的runAnalytics正在运行,而不是当我按下我的按钮命令时 . main.py import runAnalytics import tkinter import os import centerWindow loadApplication = tkinter.T... -
1 votesanswersviews
如何在ubuntu 16.04上为python 3.5安装wx
如何在Ubuntu 16.04上为python 3.5安装wx最新版本? 我得到的错误: ~$ sudo apt-get install python3-wxgtk3.0 读取包列表...完成构建依赖关系树读取状态信息...完成包python3-wxgtk3.0不可用,但由另一个包引用 . 这可能意味着包丢失,已被淘汰或仅可从其他来源获得E:包'python3-wxgtk3.0'没有安装候选 ... -
0 votesanswersviews
Python使用alernating变量下载图像
我试图下载带有url的图像,但是发生了错误 . url_image="http://www.joblo.com/timthumb.php?src=/posters/images/full/"+str(title_2)+"-poster1.jpg&h=333&w=225" user_agent = 'Mozilla/5.0 (Windows ... -
14 votesanswersviews
aiohttp.TCPConnector(带限制参数)vs asyncio.Semaphore用于限制并发连接数
我想我想通过制作一个简单的脚本来学习新的python异步等待语法,更具体地说是asyncio模块,它允许你在一个下载多个资源 . 但现在我被卡住了 . While researching I came across two options to limit the number of concurrent requests: 将aiohttp.TCPConnector(带限制参数)传递给aio... -
0 votesanswersviews
kubernetes python3.5 SSLError(“坏握手:错误([('SSL routines','ssl3_get_server_certificate','certificate verify failed')],)”,)
我按照例子说明: from kubernetes import client, config config.load_kube_config() v1 = client.CoreV1Api() print("Listing pods with their IPs:") ret = v1.list_pod_for_all_namespaces(watch=False) for... -
21 votesanswersviews
解压缩一般化
>>> LOL = [[1, 2], ['three']] >>> [*LOL[0], *LOL[1]] [1, 2, 'three'] 好的!再见itertools.chain . 反正从来没有喜欢过你 . >>> [*L for L in LOL] File "<ipython-input-21-e86d2c09c33... -
0 votesanswersviews
UnicodeDecodeError:'ascii' codec无法解码位置7601中的字节0xc3:序数不在范围内(128)
我目前正在运行:Python 3.5.1 :: Anaconda 4.0.0(x86_64) . 错误:UnicodeDecodeError:'ascii'编解码器无法解码位置7601中的字节0xc3:序数不在范围内(128) 运行以下代码时,我收到上述错误 . 当我保存并尝试从本地directy打开txt文件时,我遇到了同样的错误,但是,当我保存并运行一个副本时,我按照预期缩短到~25行 - 任... -
1 votesanswersviews
如何识别并适当地解析由Python创建的csv数据中的列表
我正在使用Python导出和导入CSV数据 . 当写入CSV时,某些单独的段/值最初是列表 . python CSV库将这些值输出为由方括号括起的CSV . 当我读回数据时,也使用CSV库,它无法识别列表的存在,而是将其作为单个字符串读取 . 有什么方法可以将列表作为列表而不是字符串读回来吗?我宁愿不使用split(',')手动操作字符串 . import csv dummy_data = [... -
1 votesanswersviews
tkinter.Listbox滚动条yview
我再次遇到编写Python的一些问题,并希望寻求我的帮助 . 我继续构建我的Listbox小部件但无法设置滚动条 . 我可以将Scrollbar放在正确的位置,但是,向上和向下只是不工作并弹出一个错误,说“对象()没有参数” . 任何人都可以建议如何解决它?我附上以下代码供参考 . import tkinter from tkinter import * def test(): root... -
110 votesanswersviews
与Python 3.4相比,为什么Python 3.5中的str.translate要快得多?
我试图在Python 3.4中使用 text.translate() 从给定的字符串中删除不需要的字符 . 最小的代码是: import sys s = 'abcde12345@#@$#%$' mapper = dict.fromkeys(i for i in range(sys.maxunicode) if chr(i) in '@#$') print(s.translate(mapper))... -
0 votesanswersviews
使用Keras .h5文件从视频流中检测对象
我正在使用keras和tensorflow来训练使用转移学习的自定义模型 . 我想知道,是否有任何教程使用keras .h5文件从实时视频流中检测自定义对象?以下是基于https://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/5.3-using-a-pretrained-convnet.ipynb的培训示... -
0 votesanswersviews
Odoo 12字数
如何在Odoo 12中使用num2words库来显示发票报告中的总金额? 我在/base/modules/res_currency.py中找到了num2words函数 @api.multi def amount_to_text(self, amount): self.ensure_one() def _num2words(number, lang): try: ... -
0 votesanswersviews
尝试在Python 3.5中运行Sanic应用程序的未定义符号
当我尝试使用Python 3.5运行Sanic应用程序时,我收到以下错误: Traceback (most recent call last): File "api.py", line 1, in <module> from sanic import Sanic File "/home/shiro/dev/unassociated/user... -
2 votesanswersviews
ImportError:没有名为'_sqlite3'的模块
每当我导入sqlite3时,它都会导致导入错误 . 谁能告诉我如何为python3导入sqlite3 . 另外,我在我的vps上使用CentOS 6.5 . 回溯(最近一次调用最后一次):文件“", line 1, in File " /usr/local/lib/python3.5/sqlite3/ init .py ", line 23, in from sql... -
5 votesanswersviews
ASYNCIO . 动态添加协程到循环
我正在编写应用程序,它每秒扫描目录,检查新文件,如果它们出现 - 通过POST请求发送它们并执行存档 . 假设可以出现在目录中的文件数量可以从10到100 - 我决定使用asyncio和aiohttp来同时发送请求 . 码: import os import aiohttp from aiohttp.client import ClientSession BASE_DIR = '/path/t... -
16 votesanswersviews
通过参数或使用默认的asyncio循环传递asyncio循环
我对于将事件循环作为参数传递感到困惑 . 使用事件循环编写函数/方法时有三种可能性: 将asyncio事件循环作为参数传递 不要为事件循环使用参数并使用 asyncio.get_event_loop() 使其可选,将事件循环作为参数传递 . 如果未通过,请使用 asyncio.get_event_loop() 似乎最后一种情况大部分时间都在使用,但即使在asyncio api中,使... -
0 votesanswersviews
Python asyncio - 使用asyncio.Event()阻止消费者
我有一个程序有一个 生产环境 者和两个 slow 消费者,我想用协同程序重写它,以便每个消费者将处理为它生成的 only last value (即跳过处理旧的生成的新值)(我使用了线程和 threading.Queue() 但是在 put() 上有块,导致队列大部分时间都是满的 . 阅读answer to this question后,我决定使用 asyncio.Event 和 asyncio.... -
0 votesanswersviews
Python Tkinter滚动条画布不起作用
我无法让滚动条适用于tkinter框架 . 我希望能够滚动的框架是由导入的SQL内容组成的网格 . 我已将此框架包含在画布中(如其他帖子中所示) . 当我加载特定的屏幕时,画布会在非常小的空间中加载,其中包含几个SQL内容标签和后面的滚动条 . 使用滚动条时,画布会扩展以填充适当的大小,并且它可以正常工作 . 以下是使用滚动条之前和之后的两个屏幕截图: 在使用滚动之前: 滚动后使用: 以下是此... -
0 votesanswersviews
sqlite3.ProgrammingError:提供的绑定数量不正确 - sqlite检测到的数字不正确
我知道关于同一主题有很多问题,但是,我没有找到解决我问题的方法 . 据我所知,这不是一个元组问题 . 我将2的元组传递给带有2个问号的查询 . Sqlite说它只需要1 . 码: def getRecipeId(categoryId, name): query = "SELECT id from tbl_recipes where name = '?' and categoryId... -
-1 votesanswersviews
python错误:靠近“From”:语法错误
我试图在数据库中的单独列中插入6个值,并且在运行我的代码时,我接近“From”语法错误可以有人帮忙吗? def setup_transactions(db, filename): '''(str, str) -> NoneType Create and populate the Transactions table for database db using the ... -
1 votesanswersviews
Unicode Dict键问题
使用python 3.5 . 据我所知,默认情况下所有字符串都应该是unicode . 为什么这些unicode键名使用ascii编码? row_map = { 'α-Pinene': 7, 'β-Pinene': 8, 'Terpinolene': 9, 'Geraniol': 10, ... -
3 votesanswersviews
AttributeError:'module'对象没有属性'lru_cache'
我正在使用此环境设置获得 Headers 中显示的错误 . Apache2与mod_wsgi,Python 3.5,Django 2.0.2 . 我正在使用virtualevn . 我的虚拟环境在:/ home / santosh / Documents / project / project /和django app在/ home / santosh / Documents / project... -
0 votesanswersviews
如何在data_received中更正asyncio yield
我会在data_received函数中向数据库发出异步请求,但我不知道怎么做 . 我用asyncio.sleep(2)编写了简单的HTTPServer,但它不起作用 . import time import asyncio class HTTPServer: def connection_made(self, transport): self.transport = tr... -
0 votesanswersviews
Python 3:用XPath错误解析html
我是python 3的新手 . 我正在使用XPath削减html数据 . 我使用pycharm编译我的代码,我的代码如下所示 . 请帮我修复问题(请不要使用美丽的汤) . 我知道很多关于用python 2 xpath解析html的代码,如果你有一些关于用python 3 xpath解析html的材料链接,请告诉我 . 我在pycharm中安装了lxml和request库 . 此外,终端默认是pyt...