我是gulp的新手,我按照http://leveluptuts.com/tutorials/learning-gulp中的教程,我收到此错误:
events.js:141
throw er; // Unhandled 'error' event
^
Error
at new JS_Parse_Error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:196:18)
at js_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:204:11)
at croak (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:680:9)
at token_error (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:688:9)
at unexpected (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:694:9)
at expr_atom (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1201:9)
at maybe_unary (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1363:19)
at expr_ops (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1398:24)
at maybe_conditional (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1403:20)
at maybe_assign (/home/kid/node_modules/gulp-uglify/node_modules/uglify-js/lib/parse.js:1427:20)
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
var gulp = require('gulp')
uglify = require('gulp-uglify');
gulp.task('default', function() {
// body...
gulp.src('js/*.js')
.pipe(uglify())
.pipe(gulp.dest('minjs'));
});
Run Code Online (Sandbox Code Playgroud)
和目录树,只是简单
-gulp
-js/
-gulpfile.js
Run Code Online (Sandbox Code Playgroud)
非常感谢
我试图理解这种分裂方法的逻辑过程.
我们可以从中获得多大的分割质量?这是拆分数据集的推荐方法吗?
# We want to ignore anything after '_nohash_' in the file name when
# deciding which set to put an image in, the data set creator has a way of
# grouping photos that are close variations of each other. For example
# this is used in the plant disease data set to group multiple pictures of
# the same leaf.
hash_name = re.sub(r'_nohash_.*$', '', file_name)
# This looks …Run Code Online (Sandbox Code Playgroud)从 djangobook(第 7 章 - 表单)中的示例中学习 django 时,我收到此错误。
完整错误:/contact/ 处的错误
[Errno 111] 连接被拒绝
请求方法:POST 请求 URL: http://localhost:8000/contact/ Django 版本:1.8.4 异常类型:错误异常值:
[Errno 111] 连接被拒绝
异常位置:/usr/lib/python2.7/socket.py in create_connection,第 571 行 Python 可执行文件:/usr/bin/python Python 版本:2.7.6
这是代码:
视图.py
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
cd['subject'],
cd['message'],
cd.get('email', 'noreply@example.com'),
['siteowner@example.com'],
)
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()
return render(request, 'contact_form.html', {'form': form})
Run Code Online (Sandbox Code Playgroud)
请解决这个错误,非常感谢
我在Heroku中部署了一个简单的Django应用
脚步:
- git push heroku master
- heroku run python manage.py makemigrations ( or + app_name)
Run Code Online (Sandbox Code Playgroud)
它似乎影响:
0002_main.py:
- Create model Comment
- Remove field status from match
- Remove field quantity from slot
- Add field avatar to account
- Add field slots to match
- Alter field verification_code on account
- Alter field verification_code on slot
- Add field match_object to comment
- Add field user to comment
- Alter index_together for comment (1 constraint(s))
Run Code Online (Sandbox Code Playgroud)
然后我跑
- …Run Code Online (Sandbox Code Playgroud) 下面的示例代码使用bimg将pdf转换为jpeg 。
func main() {
buffer, err := bimg.Read("test.pdf")
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
newImage, err := bimg.NewImage(buffer).Convert(bimg.JPEG)
if err != nil {
fmt.Fprintln(os.Stderr, err)
}
if bimg.NewImage(newImage).Type() == "jpeg" {
fmt.Fprintln(os.Stderr, "The image was converted into jpeg")
}
bimg.Write("test.jpg", newImage)
}
Run Code Online (Sandbox Code Playgroud)
但只会转换的第1页test.pdf。
有什么方法可以转换成包含多个页面的图像。
我想将字符串转换为日期时间。
字符串是:
date_created = "2016-10-22T16:27:54+0000"
Run Code Online (Sandbox Code Playgroud)
我正在尝试将其转换为:
datetime.strptime(date_created, '%y-%m-%dT%H:%M:%S+0000')
Run Code Online (Sandbox Code Playgroud)
但格式不匹配。
那么,要使用的正确格式是什么?
抱歉这个愚蠢的问题。
我不知道在哪里可以找到此解决方案或任何关键字参考。
比方说,我有 2 个模型 Place 和 Tips,并且:
# list of place id
place_id_list = [...]
Run Code Online (Sandbox Code Playgroud)
如何在 place_id_list 上过滤提示,该列表仅为每个地方检索 <= 5 个提示对象
这是模型:
class Place:
...
class Tip:
# object_id is id of place
object_id = models.PositiveIntegerField(editable=False)
content_type = models.ForeignKey(ContentType)
Run Code Online (Sandbox Code Playgroud)
现在,我只使用for 循环,如:
tip_list = []
for place_id in place_id_list:
tip_list += Tip.objects.filter(object_id=place_id, content_type...)[0:5]
Run Code Online (Sandbox Code Playgroud)
但是这个查询似乎很慢。
有没有更好的解决办法?
谢谢。
假设我有一个结构看起来像:
type Employee struct {
ID uint32 `json:"id" sql:"id"`
FirstName string `json:"first_name" sql:"first_name"`
LastName string `json:"last_name" sql:"last_name"`
Department struct {
Name string `json:"name" sql:"name"`
Size int `json:"size" sql:"size"`
}
}
Run Code Online (Sandbox Code Playgroud)
下面的代码无法从嵌套的struct Department获取标记
func main(){
t := reflect.TypeOf(&Employee{}).Elem()
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
column := field.Tag.Get("sql")
fmt.Println("column: ", column)
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
column: id
column: first_name
column: last_name
column:
Run Code Online (Sandbox Code Playgroud)
有没有办法从嵌套结构中获取标签?谢谢.
假设我有一个struct Profile和sql 表profiles。
type Profile struct {
ID int `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Age int `json:"age"`
}
Run Code Online (Sandbox Code Playgroud)
并且,我从配置文件表中获取一条记录,分配到配置文件结构中。
这些字段允许 null,因此我在分配给结构之前使用sql.NullString、sql.NullInt64、pq.NullTime检查有效值。
// ... DB.Query(...)
// ... rows.Next()
// ... rows.Scan()
// ...
if firstName.Valid {
p.FirstName = firstName.String
}
if lastName.Valid {
p.LastName = lastName.String
}
if age.Valid {
p.Age = age.Int64
}
// ...
Run Code Online (Sandbox Code Playgroud)
如果我有超过 10 个表,每个表有超过 30 …
详细说明,例如:我有工作日列表:
list_week_day = [0,2,4,5,6]
Run Code Online (Sandbox Code Playgroud)
如果today.weekday()= 3,则命令list_week_day = [4,5,6,0,2]
那么,该怎么做?