小编Sea*_*ais的帖子

"def post"和"if.request.method == POST"是一样的吗?

def postif.request.method == POST一样吗?

我见过一些使用def post(self, request)和一些使用if.request.method == 'POST'.他们似乎都工作,至少我看到的任务.

有区别吗?

python django

3
推荐指数
1
解决办法
741
查看次数

Django 1.8:/:'str'对象的AttributeError没有属性'copy'

我一直在尝试Django 1.8.1.到目前为止,直到我测试它一直很好.当我去localhost:8000Django服务文件的地址()时,我得到错误:
AttributeError at /: 'str' object has no attribute 'copy'

我有一个fb_auth在Django中调用的应用程序.这是目录树.
/path/to/project/directory | ---.gitignore | ---project_foo | ---project_foo ---fb_auth ---templates ---<stuff>

在追溯中,我可以看到这个突出显示的行,这是我的观点. return render(request, 'login.html')

这是我的views.py:

from django.shortcuts import render_to_response, redirect, render    
from django.contrib.auth import logout as auth_logout    
from django.contrib.auth.decorators import login_required    

def login(request):    
    return render(request, 'login.html')    

@login_required(login_url='/')    
def vote(request):    
    return render_to_response('vote.html')    

def logout(request):     
    auth_logout(request)    
    return redirect('/')
Run Code Online (Sandbox Code Playgroud)

这是我的urls.py(如果这有帮助):

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^admin/', …
Run Code Online (Sandbox Code Playgroud)

python django

2
推荐指数
1
解决办法
3326
查看次数

烧瓶中的多个路由 - Python

我是烧瓶的初学者 - Python.我面临着多路由的问题.我经历过谷歌搜索.但是没有完全了解如何实现它.我开发了一个烧瓶应用程序,我需要为不同的URL重用相同的视图函数.

@app.route('/test/contr',methods=["POST", "GET"],contr=None)
@app.route('/test/primary', methods=["POST", "GET"])
def test(contr):                                          
    if request.method == "POST":
        if contr is None:
            print "inter"
        else:
            main_title = "POST PHASE"
...
Run Code Online (Sandbox Code Playgroud)

我想为2路由调用测试功能..并且在功能上有所不同,除了所有其他功能都相同.所以我虽然重用.但是没有得到如何使用从将调用重定向到此测试函数的函数传递的一些参数来区分测试函数内的路由.

我找不到一个很好的教程,从头开始定义多个路由的基础知识

python flask

2
推荐指数
1
解决办法
3297
查看次数

如何将字符串分成五个块?

所以程序会读取一个带字符串的文件.然后该字符串将保存到另一个文件中,但该字符串将被拆分为5个组.

例.

鉴于其内容file1.txt将是thecatsatonthemat,内容file2.txt将是theca tsato nthem at.

python string chunking

1
推荐指数
1
解决办法
1701
查看次数

在Python中找到小数点后的数字

您如何找到小数点后的数字,如下所示:123.44小数部分的第一个数字为4。如何在python中找到该数字?

python

1
推荐指数
1
解决办法
638
查看次数

找不到类型或命名空间名称"register"

当我在C#中链接表单时,我总是遇到这个问题.这是第一种形式的代码:

using ybird;

public partial class form1 : Form
{
    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
        try
        {
            register form = new register();
            register.Show();
        }
        catch (Exception w)
        {
            MessageBox.Show(w.Message, Application.ProductName);
        }
    }
 }
Run Code Online (Sandbox Code Playgroud)

这是Register.cs的代码:

namespace ybird
{
    public partial class register : Form
    { 
    }
}
Run Code Online (Sandbox Code Playgroud)

我做错了什么?

.net c# namespaces compiler-errors

-6
推荐指数
1
解决办法
243
查看次数

标签 统计

python ×5

django ×2

.net ×1

c# ×1

chunking ×1

compiler-errors ×1

flask ×1

namespaces ×1

string ×1