我没有太多的python经验,但我正在学习**kwargs.
阅读了很多,我理解了一些事情,**kwargs但我有一个小问题,或者我不理解正确的事情.
这样可行:
def test_var_kwargs(farg, **kwargs):
print "formal arg:", farg
for key in kwargs:
print "another keyword arg: %s: %s" % (key, kwargs[key])
test_var_kwargs(farg=1, myarg2="two", myarg3=3)
Run Code Online (Sandbox Code Playgroud)
并打印:
正式的arg:1
另一个关键字arg:myarg2:两个
另一个关键字arg:myarg3:3
但是,如果该函数是一个实例函数,则self必须包括:
def test_var_kwargs(self, farg, **kwargs):
print "formal arg:", farg
for key in kwargs:
print "another keyword arg: %s: %s" % (key, kwargs[key])
self.test_var_kwargs(farg=1, myarg2="two", myarg3=3)
Run Code Online (Sandbox Code Playgroud)
但这会产生错误:
TypeError: test_var_kwargs() takes exactly 2 arguments (1 given)
Run Code Online (Sandbox Code Playgroud)
我明白我必须通过自我:
self.test_var_kwargs(self, …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我routeUpdate用来检查$location.search字符串是否已更改并在我的视图中相应地导航.像这样.
$scope.$on('$routeUpdate', function(next, current) {
var slide_key = $location.search().slide_key;
if (slide_key)
$scope.go_to_slide(slide_key);
});
Run Code Online (Sandbox Code Playgroud)
还要记住,我使用reloadOnSearchfalse来重新加载控制器.
通常我通过改变它来触发它$location.search并且工作正常
一切正常但有一种情况我想在不改变搜索参数的情况下触发此行为.
我试图将搜索参数再次更改为相同的值 - >没有运气.
如果我将其更改为另一个值,那么routeUpdate火灾和一切正常.
那么如何在routeUpdate不改变params值的情况下手动触发$location.search?
我正在使用ng-style在我的一个指令中传递样式.
像这样:
<my-component ng-style="test()" ng-model="message"></my-component>
Run Code Online (Sandbox Code Playgroud)
指令:
myModule.directive('myComponent', function(mySharedService) {
return {
restrict: 'E',
controller: function($scope, $attrs, mySharedService) {
$scope.test = function(){
console.log(1)
};
$scope.$on('handleBroadcast', function() {
$scope.message = 'Directive: ' + mySharedService.message;
});
},
replace: true,
template: '<input>'
};
});
Run Code Online (Sandbox Code Playgroud)
为什么test函数调用了2次?
您好,我读到 Firestore 最大文档大小的限制为 1MiB。
我想存储心率和其他“活动”数据,我当前的模型与此类似
-activity
- HR points stream (1 point per second up to 86400 points)
- Lat points stream (same as above)
- Long points stream (same as above)
Run Code Online (Sandbox Code Playgroud)
例如,上面的数字(86400)是24小时的存储时间。
总的来说,我正在尝试存储并获得某人所做的24小时跑步。
然而,由于 Firestore 的大小限制,这是可以预测的。
您能否建议或指导人们如何存储此类“大”数据的正确方向?
我尝试将上述流分离到它们自己的文档中,但运气不佳,因为心率流甚至可以获得太多数据供火风暴存储。
那么简而言之,对于仅使用 Firestore 存储大数据流而不使用云存储等方式的建议是什么?
angularjs ×2
arguments ×1
bigdata ×1
firebase ×1
javascript ×1
kwargs ×1
modeling ×1
python ×1
python-2.7 ×1