我LocalTarget在项目中的Luigi管道中编写二进制文件时遇到了麻烦.我在这里解决了这个问题:
class LuigiTest(luigi.Task):
def output(self):
return luigi.LocalTarget('test.npz')
def run(self):
with self.output().open('wb') as fout:
np.savez_compressed(fout, array=np.asarray([1, 2, 3]))
Run Code Online (Sandbox Code Playgroud)
我尝试打开'w','wb'但我不断收到以下错误:
TypeError: write() argument must be str, not bytes
Run Code Online (Sandbox Code Playgroud)
我使用的是python 3.5.1,我的luigi版本是2.1.1
我在单击圈子时在网页上显示一些信息,现在我想在双击时添加一些交互:打开一个新的选项卡,加载一个有希望使用的URL OpenURL.
这是我目前的代码:
p = bokeh.plotting.figure(tools=TOOLS)
cr = p.circle(y_true[:, 1], y_pred[:, 1], size=5, source=source)
taptool = p.select(type=bokeh.models.TapTool)
taptool.callback = bokeh.models.CustomJS(args={'circle': cr.data_source},
code=self.show_data_callback())
Run Code Online (Sandbox Code Playgroud)
show_data_callback 只返回一个带有JS代码的字符串,该代码显示有关被点击的圆圈的信息.
我对 Python 的奇妙世界很陌生。下面的刮板产生一个对象不可调用错误,我真的不明白为什么会这样。非常感谢任何帮助
from urllib.request import urlopen
from bs4 import BeautifulSoup
html = urlopen("https://www.maxxim.de/lte-mini-sms1?maxxim=7hs6q1jfl95fip6qumcum4rfh4")
bsObj = BeautifulSoup(html,"html.parser")
nameList = bsObj.findall("h2")
for name in nameList:
print (name.get_text())
Run Code Online (Sandbox Code Playgroud)