6 回答

HUH函数
TA贡献1836条经验 获得超4个赞
%s是代表字符串, 如果你学过C语言就会知道这个。
在字符串里面加个 %s, 然后在字符串后面加上 %(变量名)就可以用后面的变量名所指向的字符串代替原有字符串中的 %s
当然,可以用 %d 代替整数型等等
比如
12 | a = 100 print "The value of a is %d" % a |
还可以这么做
12 | a = 100 print "The value of a is {}" . format (a) |
这样可以用一对花括号来表示空位,然后在后面的 format 函数里依次填入你要输出的变量名,可以有多个空,但是花括号的对数和后面 format 函数的返回值的个数一定要相同
比如
123 | a = 100 b = 200 print "The value of a is {}, the value of b is {}" . format (a, b) |

呼唤远方
TA贡献1856条经验 获得超11个赞
如果写成 print "The value of a is %d, the value of b is %d" %a,%b 就对了。 不过建议你用上面的format函数,这样就不用管类型了。 %d代表整数,%s代表字符串,其他的是我帮你找出来的,括号里是C语言里面用的,其他Python和C语言用法一样。 %d:输入输出为整形 %s:输入输出为字符串 %c字符%f:输入输出为浮点型 (%lf双精度浮点型) (%ld 长整型 %hd短整型 %hu无符号整形 %u %lu)

哆啦的时光机
TA贡献1779条经验 获得超6个赞
整数是指数学上的整数,无范围限制。django中的整型是指Python的短整型,长整型等数据类型,都有范围限制。python中短整型的取值范围[-2417483648,2417483647],如果超过这个范围怎么办呢?就可以使用长整型数,不过在结尾必须写上大写的“L”,小写也可。但是为了避免与1混淆,建议用L

慕沐林林
TA贡献2016条经验 获得超9个赞
null:
If True, Django will store empty values as NULL in the database. Default
is False.
如果为True,空值将会被存储为NULL,默认为False。
blank:
If True, the field is allowed to be blank. Default is False.
如果为True,字段允许为空,默认不允许。
添加回答
举报
0/150
提交
取消