我在virtualenv中安装pytz时遇到问题.
下载/解压缩pytz
无法找到满足要求pytz的版本(版本:2009r,2008b,2009f,2008c,2007g,2011g,2005m,2011e,2007f,2011k,2007k,2006j,2008h,2008i,2011e,2008a, 2009e,2006g,2011j,2010l,2005m,2008i,2005k,2008g,2007c,2007i,2009l,2009r,2006j,2011k,2007d,2006p,2009i,2009u,2007i,2009f,2010g,2008h,2009a,2007g,2011e, 2006p,2012b,2010k,2005r,2007f,2009l,2009p,2008c,2009j,2008g,2010g,2010h,2011h,2010k,2007c,2007d,2011d,2009l,2011c,2008a,2005m,2007k,2009n,2011d,2010o, 2013b,2012h,2010e,2012c,2012d,2012f,2011n,2011b,2011j,2008c,2012j,2007k,2009f,2009d,2010e,2010b,2013b,2011d,2009p,2008h,2005r,2009i,2009n,2009a,2010k, 2008g,2006g,2008b,2012c,2009i,2007g,2012c,2010h,2011n,2012g,2007d,2008a,2009u,2012g,2010o,2006p,2010b,2009u,2012d,2011k,2012f,2009a,2007f,2011h,2010l, 2009j,2011g,2009g,2009g,2005r,2011c,2012g,2009g,2012d,2009j,2010o,2007c,2010g,2006g,2009d,2010h,2005k,2006j,2010b,2009n,2011g,2011c,2012b,2009e,2009d,2011j,2007i,2012j,2010l,2009r,2012h,2010e,2009p,2008i,2012f,2009e,2012b, 2011h,2005k,2008b,2013b,2011n,2012j,2004b)
清理......
没有匹配pytz版本的发行版
这似乎是最新版本的pip的一个问题.
有没有解决方法?
好吧,我厌倦了尝试.
该onEnter方法不起作用.知道为什么会这样吗?
// Authentication "before" filter
function requireAuth(nextState, replace){
console.log("called"); // => Is not triggered at all
if (!isLoggedIn()) {
replace({
pathname: '/front'
})
}
}
// Render the app
render(
<Provider store={store}>
<Router history={history}>
<App>
<Switch>
<Route path="/front" component={Front} />
<Route path="/home" component={Home} onEnter={requireAuth} />
<Route exact path="/" component={Home} onEnter={requireAuth} />
<Route path="*" component={NoMatch} />
</Switch>
</App>
</Router>
</Provider>,
document.getElementById("lf-app")
Run Code Online (Sandbox Code Playgroud)
编辑:
我打电话时执行该方法onEnter={requireAuth()},但显然这不是目的,我也不会得到所需的参数.
我在JS寻找一个简单的油门.我知道像lodash和下划线这样的库有它,但只有一个函数包含任何这些库都是过度的.
我还在检查jquery是否有类似的功能 - 找不到.
我找到了一个工作油门,这是代码:
function throttle(fn, threshhold, scope) {
threshhold || (threshhold = 250);
var last,
deferTimer;
return function () {
var context = scope || this;
var now = +new Date,
args = arguments;
if (last && now < last + threshhold) {
// hold on to it
clearTimeout(deferTimer);
deferTimer = setTimeout(function () {
last = now;
fn.apply(context, args);
}, threshhold);
} else {
last = now;
fn.apply(context, args);
}
};
}
Run Code Online (Sandbox Code Playgroud)
这个问题是:它在节流时间结束后再次激活该功能.所以我们假设我在按键时每隔10秒发一个油门 - 如果我按下2次按键,它会在10秒钟完成时触发第二次按键.我不想要这种行为.
我从某个地方收到了一个DataFrame,并希望创建另一个具有相同数量和列和行(索引)名称的DataFrame.例如,假设原始数据框被创建为
import pandas as pd
df1 = pd.DataFrame([[11,12],[21,22]], columns=['c1','c2'], index=['i1','i2'])
Run Code Online (Sandbox Code Playgroud)
我通过显式定义列和名称来复制结构:
df2 = pd.DataFrame(columns=df1.columns, index=df1.index)
Run Code Online (Sandbox Code Playgroud)
我不想复制数据,否则我就可以写了df2 = df1.copy().换句话说,在创建df2之后,它必须只包含NaN元素:
In [1]: df1
Out[1]:
c1 c2
i1 11 12
i2 21 22
In [2]: df2
Out[2]:
c1 c2
i1 NaN NaN
i2 NaN NaN
Run Code Online (Sandbox Code Playgroud)
有没有更惯用的方式呢?
使用StringIO作为字符串缓冲区比使用list作为缓冲区慢.
何时使用StringIO?
from io import StringIO
def meth1(string):
a = []
for i in range(100):
a.append(string)
return ''.join(a)
def meth2(string):
a = StringIO()
for i in range(100):
a.write(string)
return a.getvalue()
if __name__ == '__main__':
from timeit import Timer
string = "This is test string"
print(Timer("meth1(string)", "from __main__ import meth1, string").timeit())
print(Timer("meth2(string)", "from __main__ import meth2, string").timeit())
Run Code Online (Sandbox Code Playgroud)
结果:
16.7872819901
18.7160351276
Run Code Online (Sandbox Code Playgroud) 我正在尝试从jQuery 1.x升级到jQuery 2.x.
我有jQuery 1.8和jQueryUI 1.8,现在我想升级到jQuery 2.x并增强我的web应用程序.
所以我的问题是如何改变和删除,比如Ajax和事件.
就像我正在谈论的这些错误一样
Uncaught TypeError: Object [object Object] has no method 'live'
Run Code Online (Sandbox Code Playgroud)
像.on()和.ajax()这样的函数是否会改变?(我知道.live已被弃用).
PS我必须添加使用jQuery 2的Zurb Foundation 5.
我import cv在我的python代码中遇到了麻烦.
我的问题是我需要在图像中的感兴趣区域周围绘制一个矩形.怎么能在python中完成?我正在进行物体检测,并希望在我相信我在图像中找到的物体周围绘制一个矩形.
我有一个全新安装yarn(通过npm install yarn -g)并试图安装一些包
yarn add vue-loader babel-loader style-loader css-loader file-loader webpack
Run Code Online (Sandbox Code Playgroud)
我在安装过程中收到了一些警告,例如
warning "vue-loader@13.3.0" has unmet peer dependency "vue-template-compiler@^2.0.0".
Run Code Online (Sandbox Code Playgroud)
这究竟是什么意思,具体而言:为什么不自行yarn安装这些依赖项?(如果需要的话)
关于同一主题的姐妹问题(关于npm)产生一些答案,其表明i)更新npmii)删除node_modules因为存在npm关于处理依赖性的错误.
这种警告的状态是什么yarn?这真的是一个警告(=我可以丢弃的东西)?我不能丢弃它们(webpack构建失败)并且必须手动安装它们.同时,安装了很多依赖项,所以我不明白为什么会错过一些(虽然它们可以手动安装)
我编写了一个简单的脚本,对一系列文件执行系统命令.为了加快速度,我想并行运行它们,但不是一次全部运行 - 我需要控制同时运行的命令的最大数量.什么是最简单的方法来解决这个问题?
我正在写一个简单的网站,作为一个成语输入,并从牛津词典返回其含义和例子.这是我的想法:
我向以下网址发送请求:
http://www.oxfordlearnersdictionaries.com/search/english/direct/?q=[idiom]
Run Code Online (Sandbox Code Playgroud)
例如,如果成语"不太远",我会发送一个请求:
http://www.oxfordlearnersdictionaries.com/search/english/direct/?q=not+go+far
Run Code Online (Sandbox Code Playgroud)
我将被重定向到以下页面:
http://www.oxfordlearnersdictionaries.com/definition/english/far_1#far_1__192
Run Code Online (Sandbox Code Playgroud)
在这个页面上,我可以提取成语的含义和例子.这是我的测试代码.它会提醒响应网址:
<input id="idiom" type="text" name="" value="" placeholder="Enter your idiom here">
<br>
<button id="submit" type="">Submit</button>
<script type="text/javascript">
$(document).ready(function(){
$("#submit").bind('click',function(){
var idiom=$("#idiom").val();
$.ajax({
type: "GET",
url: 'http://www.oxfordlearnersdictionaries.com/search/english/direct/',
data:{q:idiom},
async:true,
crossDomain:true,
success: function(data, status, xhr) {
alert(xhr.getResponseHeader('Location'));
}
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
问题是我有一个错误:
跨源请求已阻止:同源策略不允许在http://www.oxfordlearnersdictionaries.com/search/english/direct/?q=by+far上读取远程资源.这可以通过将资源移动到同一域或启用CORS来解决.
谁能告诉我如何解决这个问题?另一种方法也很好
python ×5
jquery ×3
javascript ×2
ajax ×1
cross-domain ×1
dataframe ×1
draw ×1
opencv ×1
pandas ×1
pip ×1
pytz ×1
react-router ×1
reactjs ×1
stringio ×1
upgrade ×1
virtualenv ×1
yarnpkg ×1