class MyForm(forms.Form):
CHOICES = (('1', 'one',), ('2', 'two',))
one_or_two = forms.ChoiceField(widget=forms.RadioSelect, initial='1')
def show(request):
form = MyForm()
# render form
Run Code Online (Sandbox Code Playgroud)
如何使字段one_or_two只读?
我的路线文件看起来像
GET / controllers.Application.index()
POST /get_token controllers.Application.getToken()
Run Code Online (Sandbox Code Playgroud)
GET '/' 工作正常。但是,“/get_token”的 POST 失败并显示以下错误消息。
[error] p.nettyException - Exception caught in Netty
java.lang.IllegalArgumentException: invalid version format: =D??$_!HB?H??W(?+?/????
at org.jboss.netty.handler.codec.http.HttpVersion.<init>(HttpVersion.java:102) ~[netty.jar:na]
at org.jboss.netty.handler.codec.http.HttpVersion.valueOf(HttpVersion.java:62) ~[netty.jar:na]
at org.jboss.netty.handler.codec.http.HttpRequestDecoder.createMessage(HttpRequestDecoder.java:75) ~[netty.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:189) ~[netty.jar:na]
at org.jboss.netty.handler.codec.http.HttpMessageDecoder.decode(HttpMessageDecoder.java:101) ~[netty.jar:na]
at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:500) ~[netty.jar:na]
Run Code Online (Sandbox Code Playgroud)
我正在使用 play-2.2.1。
我比较新玩。有人可以帮我吗?
提前致谢!
如何execlp()使用可变数量的参数调用不同的进程?
我有这个非常基本的问题,
>>> from django.core import serializers
>>> serializers.serialize("json", {'a':1})
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/django/core/serializers/__init__.py", line 87, in serialize
s.serialize(queryset, **options)
File "/usr/lib/pymodules/python2.6/django/core/serializers/base.py", line 40, in serialize
for field in obj._meta.local_fields:
AttributeError: 'str' object has no attribute '_meta'
>>>
Run Code Online (Sandbox Code Playgroud)
如何才能做到这一点?
我试图在节点控制台中使用下划线的键功能,如下所示
$node
> require('./underscore.js')
...
> _.keys
[Function: keys]
> _.keys
undefined
Run Code Online (Sandbox Code Playgroud)
为什么键功能消失?我在这里错过了什么吗?
基本上我想要的是两个表的交叉产品.
t1 is :
+------------+
| student |
+------------+
| 1234567890 |
| 1234567890 |
| 1234567890 |
| 000000001 |
+------------+
t2 is:
+--------+
| number |
+--------+
| 1 |
| 3 |
+--------+
Run Code Online (Sandbox Code Playgroud)
如何获得一个包含两列和八个条目的表格,这些条目是t1和t2中值的交叉乘积?
假设我有一个字符串模块的路径module_to_be_imported ='abmodule'
如何导入它?
在下面的代码中,我只需使用jython从java代码执行test.py.
public static void main(String[] args) {
org.python.util.PythonInterpreter python = new org.python.util.PythonInterpreter();
python.execfile("test.py");
...
Run Code Online (Sandbox Code Playgroud)
我的问题是test.py需要在运行jar文件的同一目录中.
我需要将这个test.py捆绑在jar中,并且仍然可以使用jython执行它.
在如何使用python调用jar文件中的python脚本中建议的方法?使用ClassLoader类中的getResourceAsStream方法读取字符串中的脚本对我不起作用,因为我的test.py导入了更多捆绑在jar中的python脚本.
刚接触java和jython我真的很困惑.
任何帮助将受到高度赞赏..!
我需要一个由help(some_object)中显示的文本创建的str对象.简单地类型转换为str不起作用.
>>> s = str(help(object))
>>> print s
None
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?
我不想使用*args或**kwargs,因为我无法更改函数声明.
例如:
def foo( a, b, c ) """Lets say values passed to a, b and c are 1,2 and 3 respectively"""
...
...
""" I would like to generate an object preferably a dictionary such as {'a':1, 'b':2, 'c':3} """
...
...
Run Code Online (Sandbox Code Playgroud)
有谁能建议这样做的方法?提前致谢.
我在$ 1中有temp.tar.gz
如何在另一个变量中得到'temp'?
我正在使用bash.
提前致谢.