我有一些用生成的uuid1字符串命名的图像.例如81397018-b84a-11e0-9d2a-001b77dc0bed.jpg.我想使用"find"命令找出所有这些图像:
find . -regex "[a-f0-9\-]\{36\}\.jpg".
Run Code Online (Sandbox Code Playgroud)
但它不起作用.正则表达式出了什么问题?有人可以帮我吗?
我真的很困惑.我试着编码,但错误说can't decode....
>>> "??".encode("utf8")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
我知道如何避免字符串上带有"u"前缀的错误.我只是想知道为什么在调用编码时错误是"无法解码".什么是Python在幕后做什么?
我正在使用{%trans%}模板标记.Django文档说:
{%trans%}模板标记转换为常量字符串(用单引号或双引号括起来)或变量内容:
{%trans"这是标题." %} {%trans myvar%}
https://docs.djangoproject.com/en/1.3/topics/i18n/internationalization/#trans-template-tag
我发现不可能{%trans myvar%},因为myvar在运行makemessages命令后根本不会出现在django.po文件中.
我用错了吗?有人可以帮我这个吗?
如果一个分支有两个头怎么办?几个星期前我出现了这种情况,因为某些原因我当时没有将它们合并,只是继续在一个头上开发.现在我想摆脱另一个头.我该怎么办?我应该在这么多变更后合并它们吗?
如何覆盖staticmethod并保持静态?
In [6]: class Foo(object):
...: @staticmethod
...: def foo(a, b):
...: print a + b
...:
...:
In [7]: Foo.foo
Out[7]: <function foo at 0x86a1a74>
In [8]: class Bar(Foo):
...: def foo(a, b):
...: print a - b
...:
...:
In [9]: Bar.foo
Out[9]: <unbound method Bar.foo>
Run Code Online (Sandbox Code Playgroud)
我用staticmethod试过装饰Bar's foo,它很有效.但我每次子类化时都要装饰它.
我正在使用jQuery表单插件上传文件.该插件使用隐藏的iframe
上传而不刷新页面.一切正常,除了javascript无法正常工作
生成的代码.这是我的代码:
<form id="image_form" action="" method="post" enctype="multipart/form-data">
<input type="file" id="image_file" name="image_file"><br>
<input type="submit" value="upload">
</form>
<div id="avatar_wrapper">
</div>
Run Code Online (Sandbox Code Playgroud)
此表单将图像上载到服务器,服务器将返回一些处理过的图像.
<script type="text/javascript">
$(document).ready(function() {
var options = {
success: showResponse,
dataType: 'html'
};
$('#image_form').ajaxForm(options);
$('.choose_avatar').hover(function() { /* Just for test */
alert('hello');
});
});
function showResponse(responseText, statusText, xhr, $form) {
$('#avatar_wrapper').append(responseText);
}
</script>
Run Code Online (Sandbox Code Playgroud)
responseText包含一些图像.
<img src="http://localhost/avatar/0.jpg" class="choose_avatar" choice=0>
<img src="http://localhost/avatar/1.jpg" class="choose_avatar" choice=1>
<img src="http://localhost/avatar/2.jpg" class="choose_avatar" choice=2>
Run Code Online (Sandbox Code Playgroud)
我写了这些代码来测试:
$('.choose_avatar').click(function() { /* Just for test */
alert('hello');
});
Run Code Online (Sandbox Code Playgroud)
奇怪的是,click函数对这些生成的代码不起作用.有人可以帮帮我吗?谢谢.
python ×2
ajax ×1
branch ×1
django ×1
file-upload ×1
find ×1
iframe ×1
javascript ×1
jquery ×1
linux ×1
mercurial ×1
python-2.7 ×1
python-2.x ×1
regex ×1
translation ×1
unicode ×1