试图让imagemin在Node.js中工作。这是我的代码:
var imagemin = require('imagemin');
var imageminPngquant = require('imagemin-pngquant');
var PNGImages = ['images/image1.png', 'images/image2.png'];
imagemin(PNGImages, 'build', {
plugins: [
imageminPngquant({
quality: '65-80'
})
]
});
但我不断收到错误消息:
(node:22744) UnhandledPromiseRejectionWarning: ArgumentError: Expected argument to be of type `array` but received type `string`
我在做什么错? 谢谢。
答案 0 :(得分:1)
找到了答案。
imageminPngquant抛出错误的原因是质量设置为65-80,而不是PNGImages数组。
:)
答案 1 :(得分:0)
通过质量如下
def combinationSum(self, candidates, target):
# List for storing possible all sequence of permutations
seq_list = []
# This loop will generate all possible permutation for given candidates
for i in range(1, target + 1):
# Extend given list with cartesian product of given candidates
# To calculate cartesian product set use itertools.product with candidates
# with set size ranging from 1 to target number
# This is necessary as we have to find all possible combinations
seq_list.extend([p for p in itertools.product(candidates, repeat=i)])
# Just select those sequence whose sum is target
result = [seq for seq in seq_list if sum(seq) == target]
# Return length of result set
return len(result)
s=Solution()
c=[1,2,3]
t=int(input())
print(s.combinationSum(c,t))