我想在Enum上使用random.choice.
我试过了 :
class Foo(Enum):
a = 0
b = 1
c = 2
bar = random.choice(Foo)
Run Code Online (Sandbox Code Playgroud)
但是这段代码不起作用,我怎么能这样做?
输入:
val list = List(1, 2, 3, 4)
Run Code Online (Sandbox Code Playgroud)
期望的输出:
Iterator((1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4))
Run Code Online (Sandbox Code Playgroud)
此代码有效:
for (cur1 <- 0 until list.size; cur2 <- (cur1 + 1) until list.size)
yield (list(cur1), list(cur2))
Run Code Online (Sandbox Code Playgroud)
但它似乎不是最佳的,有没有更好的方法呢?
我在一个控制器中定义了一个2D数组但是当我尝试在它上面循环时,有2个重叠的循环,它不能像预期的那样工作.第一个循环工作正常,但第二个循环不起作用.
JS/index.js
var gameOfLifeApp = angular.module('gameOfLifeApp', []);
gameOfLifeApp.controller('fieldCtrl', function ($scope) {
$scope.field = [
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
];
});
Run Code Online (Sandbox Code Playgroud)
的index.html
<!DOCTYPE HTML>
<html ng-app="gameOfLifeApp">
<head>
<meta charset="UTF-8">
<title>Game of Life</title>
<link rel="stylesheet" href="css/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>
<script src="js/index.js"></script>
</head>
<body ng-controller="fieldCtrl">
<div id="field">
<div class="column" ng-repeat="column in field">
<div class="cell" ng-repeat="cell in column"></div>
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
输出:
<body ng-controller="fieldCtrl" class="ng-scope">
<div id="field">
<!-- ngRepeat: column in field -->
<div class="column ng-scope" ng-repeat="column in field"> …Run Code Online (Sandbox Code Playgroud) 我进行了子类化PDFStreamEngine和重载processTextPosition,现在我可以像这样重建文本PDFTextStripper,但我不想处理透明文本,这通常是垃圾。
我如何知道某些文本是否透明?
angularjs ×1
arrays ×1
enums ×1
java ×1
javascript ×1
pdfbox ×1
python ×1
python-3.4 ×1
random ×1
scala ×1