python django 返回 return json遇到的问题 20C

我用django模型查询了一条数据返回为json格式
android端解析遇到了一些问题

以下是服务器返回的json格式 用List才能解析

{
        "obj":[
                {
                        "failureDate":1459782820,
                        "token":"iosjdsjfijioeru",
                        "userId":123213213,
                        "account":"8882389482394",
                        "key":"iosndfiu34248",
                        "id":8
                }
        ],
        "code":200
}

以下为理想的json格式 直接用object解析

{
        "obj":{
                        "failureDate":1459782820,
                        "token":"iosjdsjfijioeru",
                        "userId":123213213,
                        "account":"8882389482394",
                        "key":"iosndfiu34248",
                        "id":8
                },
            "code":200
}

如果我想返回一个对象第一个json是不可以的 至于第二个我还不知道怎么将django模型对象
转换成第二种json格式

花括号保存对象
方括号保存数组

请问 python django怎么才能生成没有方括号的json

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
使用JSON将Django日期时间传递到Golang服务器

<div class="post-text" itemprop="text"> <blockquote> <p>Here is my django model</p> </blockquote> <pre class="lang-py prettyprint-override"><code>class Data(models.Model): created = models.DateTimeField(null=True, blank=True, editable=False) modified = models.DateTimeField(null=True, blank=True) raw = models.TextField(null=True, blank=True) uuid = models.CharField(blank=True, null=True, max_length=48,unique=True) used = models.BooleanField(default=False,null=True) name = models.CharField(blank=True, null=True, max_length=200) geohash = models.CharField(blank=True, null=True, max_length=200) def __str__(self): return str(self.created) + ":" + str(self.raw) def __unicode__(self): return str(self.created) + ":" + str(self.raw) def save(self, *args, **kwargs): """ On save, update timestamps """ if not self.uuid : self.uuid = str(uuid.uuid4().hex) +str(random.randint(1000,9999) ) if not self.id: self.created = timezone.now() self.modified = timezone.now() # if not self.geoHash and (self.gpsLat and self.gpsLong): # Geohash.encode(self.gpsLat, self.gpsLong) return super(DataLbc, self).save(*args, **kwargs) def toJson(self): ret = {} ret["Created"] = str(self.created) ret["Modified"] = str(self.modified) ret["Used"] = self.used ret["Raw"] = self.raw return ret </code></pre> <blockquote> <p>Here is the way that i send it to my golang server :</p> </blockquote> <pre class="lang-py prettyprint-override"><code>from RawOffer.models import Data while True: try : for data in Data.objects.all()[:10]: requests.post("http://127.0.0.1:8087/convert/",json=data.toJson()) except Exception as e: print(e) time.sleep(5) </code></pre> <blockquote> <p>Now my golang server : </p> </blockquote> <pre class="lang-golang prettyprint-override"><code>package main import ( "database/sql" "encoding/json" "fmt" "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/jmoiron/sqlx" "github.com/lib/pq" "strings" "gopkg.in/guregu/null.v3" ) type RawOffer struct { RawOfferData string `json:"Raw"` Modified null.Time `json:"Modified"` Created null.Time `json:"Created"` } func convertLbc(c *gin.Context) { var rawOffer RawOffer c.BindJSON(&amp;rawOffer) fmt.Println(rawOffer.Created) var err error s := strings.Split(rawOffer.RawOfferData, `"ads": `) s2 := `{ "ads": ` + s[1] result := strings.Replace(s2, `, "status": "ready"}]`, ``, -1) //fmt.Println(result) var rawOfferLbc RawOfferLbc if err = json.Unmarshal([]byte(result), &amp;rawOfferLbc); err != nil { fmt.Println(result) panic(err) } } var db *sqlx.DB func main() { var err error fmt.Println("begin") r := gin.Default() r.Use(cors.Default()) r.POST("/convert/",convert) r.Run((":8087")) } </code></pre> <p>but for Created and modified when i try to receive it i have <code>{0001-01-01 00:00:00 +0000 UTC false}</code></p> <p>How to serialize a django datetime to send it in json and how to get it in golang?</p> <p>My main goal so is to send an object with the date from the django app to a microservice in golang. So I need to serialize the django date and I need to write a lot of text because stackoverflow won't let me post my program if i don't write enough text ...</p> <p>Regards</p> </div>

Django model,QuerySet 序列化成json报错

运行django的views.py中的代码报错如下: 'MetaDict' object has no attribute 'concrete_model' 出错的代码行是:hall_list_data = serializers.serialize("json", clientcase.objects.filter(category="hall")) 我的models.py中定义的模型如下: # *-* coding: utf-8 *-* from django.db import models from mongoengine import * from acto_website.settings import DBNAME import json import pymongo connect(DBNAME) # Create your models here. #客户案例模型 class clientcase(Document): category = StringField(max_length = 1000) name = StringField(max_length= 1000) address = StringField(max_length = 1000) introduction = StringField(max_length = 100000) store_time = IntField() pictures = ListField(DictField()) videos = ListField(DictField()) def __str__(self): return self.name 我用的model是基于mongoengine的,没有用它自己的 哪位大侠指点一下,十分感谢

自己写api的时候遇到Django响应为空,不知道有没有大佬碰到这个问题???

最近在用Django做api服务,碰到一个问题。因为这个api需要接收一张图片,所以只支持post请求。 处理逻辑如下所示: ``` if request.method == "POST": ............ else: results["status"] = 3 results["message"] = f"请求方法错误:暂不支持此类型的请求--{request.method}" return JsonResponse(results, json_dumps_params={"ensure_ascii": False}) ``` 在服务器上测试使用get请求携带图片进行访问时会出现没有相应结果的情况,但在本地测试没有任何问题。 服务器测试结果如下图: ![图片说明](https://img-ask.csdn.net/upload/201907/29/1564379929_56557.png) 本地测试结果如下图: ![图片说明](https://img-ask.csdn.net/upload/201907/29/1564380091_980126.png) 但是在服务器上使用get方法不携带图片发送请求时,却可以正常返回结果: ![图片说明](https://img-ask.csdn.net/upload/201907/29/1564380210_461255.png) 还望有明白的大佬能指点迷津,小弟在此跪谢啦!!!! 服务器: Django版本:2.1.8 python版本:3.7.2 linux版本:centos 7.6 本地环境: Django版本:2.2 python版本:3.6.1 windows版本:win10家庭版

django怎样在两个VIEWS之间传递数据

``` from django.shortcuts import render from django.views.generic.base import View from datetime import datetime from django.http import HttpResponse from .models import Cschat from tools.cschat_aliyun import AliyunCschat from django.views.decorators.csrf import csrf_exempt import json,time class CschatView(View): def get(self,request): return render(request,'cschat.html') def post(self,request): content = request.POST.get("content","") result = AliyunCschat(content).hash_result() time.sleep(2) with open('aliyun.json','rb') as f: d = json.loads(f.read()) return render(request,'cschat_result.html',{ "contents":d }) class AliyunCallbackView(View): @csrf_exempt def post(self,request): postbody = request.body with open('aliyun.json','wb') as f: f.write(postbody) return HttpResponse(str(postbody)) def get(self,request): return render(request,'aliyun_callback.html',{ "text":"没有结果" }) ``` 应用场景:给阿里云的接口发送POST请求后 阿里云不会直接返回数据 而是把数据返回到另外一个接口(class AliyunCallbackView(View)这个对应的url),我需要在给阿里云发送POST请求后从另一个接口读取阿里云返回的POST数据。 代码中 ``` result = AliyunCschat(content).hash_result() ``` 这一行执行是给阿里云的接口发送POST请求 我现在的写法很有问题,因为没有好的解决办法。 我的做法是把AliyunCallbackView接收到的阿里云POST返回的数据写到aliyun.json这个文件里面,然后等待2秒钟后读取aliyun.json里面的内容,再把结果返回给前端。这样写的问题很多,如果AliyunCallbackView在一秒内接收到多个返回数据,那后面的执行内容就全变了。可以把阿里云POST返回的数据写入数据库,然后使用时间戳查询数据库返回对应的值。这种办法虽然可行但是感觉太麻烦了,请问有什么更好的解决办法?

提问:Python Django路由分发的时候项目URL中加一个路径时手动输入url可以,自动跳转时不能自动添加路径?

Python3.8,Django3.0.6 Django路由分发的时候项目URL中加一个路径就没办法自动跳转,但是手动输入的话就可以,如果路径是空的话可以跳转,如下: ![图片说明](https://img-ask.csdn.net/upload/202005/20/1589960545_973895.png) 这样设置的时候url跳转不会自动增加/cmdb/,如果cmdb那边用空字符串不加路径的话就可以![图片说明](https://img-ask.csdn.net/upload/202005/20/1589960610_702932.png) views里是这样写的 感觉也没有执行,![图片说明](https://img-ask.csdn.net/upload/202005/20/1589960689_993652.png) 结果就是我加上/cmdb/这个路径就永远跳转到下面这个页面,百度了很多没有遇到我这个问题的,搞不懂为什么,求大佬解惑。 ![图片说明](https://img-ask.csdn.net/upload/202005/20/1589960869_545461.png) 手动输入可以,自动跳转的时候不会加上前面的路径。

django +jquery+ ajax get提交报错,post提交就可以

``` 模板:(index.html) “ <html> <body> <p>请输入两个数字</p> <form action="/index" method="get"> a: <input type="text" id="a" name="a"> <br> b: <input type="text" id="b" name="b"> <br> <p>result: <span id='result'></span></p> <button type="button" id='sum'>提交</button> </form> <!---<script type="text/javascript" src="/static/jquery-3.3.1.min.js"></script>---> <script src="http://apps.bdimg.com/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#sum").click(function(){ var a = $("#a").val(); var b = $("#b").val(); $.get("/index",{'a':a,'b':b}, function(ret){ $('#result').html(ret.result) }) }); }); </script> </body> </html>” ``` ``` **url 代码:** urlpatterns = [ url(r'testDb' , testDb), url(r'query' , Query), url(r'formdemo' , searchtest.search), url(r'^seachDemo' , searchtest.search_form), url(r'^index' , view.loginIndex), ] ``` ``` python 代码view.py: def loginIndex(request): if(request.method == 'GET'): a = int(request.GET.get('a')) b = int(request.GET.get('b')) return_json = {'result': a + b} return HttpResponse(json.dumps(return_json), content_type='application/json') return render(request,"index.html") ``` 报错: TypeError at /index int() argument must be a string, a bytes-like object or a number, not 'NoneType' Request Method: GET Request URL: http://127.0.0.1:8000/index Django Version: 2.0.3 Exception Type: TypeError Exception Value: int() argument must be a string, a bytes-like object or a number, not 'NoneType' Exception Location: D:\PythonDemo\PythonDemo\view.py in loginIndex, line 12 Python Executable: D:\PythonDemo\venv\Scripts\python.exe Python Version: 3.6.3 Python Path: ['D:\\PythonDemo', 'D:\\PythonDemo', 'D:\\PythonDemo\\venv\\Scripts\\python36.zip', 'X:\\python\\DLLs', 'X:\\python\\lib', 'X:\\python', 'D:\\PythonDemo\\venv', 'D:\\PythonDemo\\venv\\lib\\site-packages', 'D:\\PythonDemo\\venv\\lib\\site-packages\\setuptools-28.8.0-py3.6.egg', 'D:\\PythonDemo\\venv\\lib\\site-packages\\pip-9.0.1-py3.6.egg', 'X:\\PyCharm\\PyCharm 2017.3.4\\helpers\\pycharm_matplotlib_backend'] Server time: Sun, 18 Mar 2018 07:35:40 +0000 这个报错也让我很懵逼,我把提交方式,和ajax方法改成post,就没有这个报错,程序可以正常运行

带有Ajax的Python中的JSON

<div class="post-text" itemprop="text"> <p>I have had this problem for couple of days now, My response from the Django is </p> <pre><code>di = { 0 : 'bat' , 1 : 'ball' } js = json.dumps(js , indent=4) print js """ { "0": "bat", "1": "ball" } """ return HttpResponse(js) </code></pre> <p>now in my Ajax function:</p> <pre><code>$.ajax({ type: "POST", url: "/some/url", data: { 'name': "myname", csrfmiddlewaretoken: '{{ csrf_token }}' }, dataType: "json", success: function (data) { alert(data) var to_parse = $.parseJSON(data); alert(to_parse) } }); return false } </code></pre> <p>I expect in <code>alert(data)</code> the json value, but instead it get this: <code>[object object]</code></p> <p>Where am I going wrong?</p> </div>

django 用url传递一个参数时无法成功

![图片说明](https://img-ask.csdn.net/upload/201903/10/1552225984_289609.jpg) <br> 图中我访问地址如上,在urls.py中有path(r'^test2/(.*)/$),但就是访问不了view.test2 <br>![图片说明](https://img-ask.csdn.net/upload/201903/10/1552226049_269479.jpg) <br> 括号内那个不是任意匹配的正则式吗? 为什么错误提示didn't match any of these

Django和Ajax错误

<div class="post-text" itemprop="text"> <p>Testing a basic ajax form and can't figure out why i'm getting the error <strong>init</strong>() got an unexpected keyword argument 'cost'</p> <p>I'm trying to follow this <a href="https://realpython.com/blog/python/django-and-ajax-form-submissions/" rel="nofollow">https://realpython.com/blog/python/django-and-ajax-form-submissions/</a></p> <p>It worked fine with one field, but getting the error when adding in more fields into the form, so i suspect it's a simple mistake</p> <p>any thoughts? </p> <p>The View</p> <pre><code>def create_post(request): if request.method == 'POST': post_name = request.POST.get('the_name') post_cost = request.POST.get('the_cost') response_data = {} post = CostsForm(name=post_name, cost=post_cost) post.save() response_data['result'] = 'Create post successful!' response_data['postpk'] = post.pk response_data['name'] = post.name response_data['cost'] = post.cost response_data['created'] = post.created.strftime('%B %d, %Y %I:%M %p') return HttpResponse( json.dumps(response_data), content_type="application/json" ) else: return HttpResponse( json.dumps({"nothing to see": "this isn't happening"}), content_type="application/json" ) </code></pre> <p>Javascript </p> <pre><code>// AJAX for posting function create_post() { console.log("create post is working!") // sanity check $.ajax({ url : "create_post/", // the endpoint type : "POST", // http method data : { the_name : $('#post-name').val(), the_cost : $('#post-cost').val()}, // data sent with the post request // handle a successful response success : function(json) { $('#post-name').val(''), $('#post-cost').val(''); // remove the value from the input console.log(json); // log the returned json to the console $("#talk").prepend("&lt;li id='post-"+json.postpk+"'&gt;&lt;strong&gt;"+json.name+"&lt;/strong&gt; - &lt;em&gt; "+json.owner+"&lt;/em&gt; - &lt;span&gt; "+json.created+ "&lt;/span&gt; - &lt;a id='delete-post-"+json.postpk+"'&gt;delete me&lt;/a&gt;&lt;/li&gt;"); console.log("success"); // another sanity check }, // handle a non-successful response error : function(xhr,errmsg,err) { $('#results').html("&lt;div class='alert-box alert radius' data-alert&gt;Oops! We have encountered an error: "+errmsg+ " &lt;a href='#' class='close'&gt;&amp;times;&lt;/a&gt;&lt;/div&gt;"); // add the error to the dom console.log(xhr.status + ": " + xhr.responseText); // provide a bit more info about the error to the console } }); }; </code></pre> <p>The form </p> <pre><code>class SundayForm(forms.ModelForm): class Meta: model = Sunday fields = ['name','owner'] widgets = { 'name': forms.TextInput( attrs={'id': 'post-name', 'required': True, 'placeholder': 'Sunday Name..'} ), 'owner': forms.TextInput( attrs={'id': 'post-owner','required': True, 'placeholder': 'Sunday Owner..'} ) } class CostsForm(forms.ModelForm): class Meta: model = Costs fields = ['name', 'cost'] widgets = { 'name': forms.Select( attrs={'id': 'post-name', 'required': True} ), 'cost': forms.TextInput( attrs={'id': 'post-cost', 'required': True, 'placeholder': 'Sunday Cost'} ) } </code></pre> <p>------------- EDIT ------------------<br> I think i've made some progress, i have the values coming in the the java script but <code>post.save()</code> isn't the right thing to use here, any thoughts </p> <pre><code>def create_post(request): if request.method == 'POST': post_name = request.POST.get('the_name') post_cost = request.POST.get('the_cost') response_data = {} post = Costs(name_id=post_name, cost=post_cost) post.save() form = CostsForm(request.POST) if form.is_valid(): post = form.save() response_data['result'] = 'Create post successful!' response_data['postpk'] = post.pk response_data['name'] = post.name_id response_data['cost'] = post.cost response_data['created'] = post.created.strftime('%B %d, %Y %I:%M %p') return HttpResponse( json.dumps(response_data), content_type="application/json" ) else: return HttpResponse( json.dumps({"nothing to see": "this isn't happening"}), content_type="application/json" ) </code></pre> </div>

Django中的请求

<div class="post-text" itemprop="text"> <p>I'm newer in <code>Django</code> and some time ago I've totally stuck on problems with my requests. I'm trying to do <code>POST</code> from <code>Django</code> form. I do that with <code>json</code> and <code>AJAX</code> Here is my code</p> <p>form.py</p> <pre><code> class PostForm(forms.ModelForm): class Meta: model = Message fields = ['message_text'] widgets = { 'message_text': forms.TextInput( attrs={'id': 'message_text', 'required': True, 'placeholder': 'new message...', }),} </code></pre> <p>views.py</p> <pre><code> def index(request): if request.method == 'POST': form = PostForm(request.POST) if form.is_valid(): form.cleaned_data message_t = request.POST.get('message_text') response_data = {} new_mess = Message(message_text = message_t, post_time = message_t.created, username="second") new_mess.save() response_data['result'] = message_t else: response_data['result'] = 'nothing...' else: form = PostForm() template = loader.get_template('chat/index.html') context = RequestContext(request, { 'form': form, }) return HttpResponse(template.render(context)) </code></pre> <p>(In another variant of views.py I tried to separate POST request handling to another function, but it doesn't work as well)</p> <p>html:</p> <pre><code> &lt;form method="POST" id="post-form"&gt; &lt;td class="col-lg-6"&gt;&lt;div class="fieldWrapper" id="the_post" class="form-control" type="text"&gt; {{ form.message_text }} &lt;/div&gt;&lt;/td&gt; &lt;td class="col-lg-6"&gt; &lt;input type="submit" value="Post" class="btn btn-success" name = "Post"&gt;&lt;/td&gt; &lt;/form&gt; </code></pre> <p>js:</p> <pre><code> $(function() { $('#post-form').on('submit', function(event){ event.preventDefault(); console.log("form submitted!") // sanity check create_post(); }); function create_post() { console.log("create post is working!") // sanity check $.ajax({ url : "/chat/new_message/", // the endpoint type : "POST", // http method data : { the_post : $('#post-form').val() }, success : function(json) { $('#post-form').val(''); // remove the value from the input console.log(json); // log the returned json to the console console.log("success"); }, error : function(xhr,errmsg,err) { ... } }); }; }); </code></pre> <p>In the result my <code>POST</code> is successful, no error appears, but no record in the base created too. Note: Also I've excluded <code>csrf</code> everywere</p> <p>Can someone help me to figure out what's wrong?</p> </div>

不正确的json mimetype?

<div class="post-text" itemprop="text"> <p>I have followed this <a href="https://stackoverflow.com/questions/798111/how-do-i-json-serialize-a-python-dictionary">How do I JSON serialize a Python dictionary?</a> and this <a href="https://stackoverflow.com/questions/477816/the-right-json-content-type">What is the correct JSON content type?</a> to create a json response like this:</p> <pre><code>def json_response(something): return HttpResponse( simplejson.dumps(something), content_type = 'application/json; charset=utf8' ) </code></pre> <p>How ever I have two complains:</p> <p>a) When I hit my ajax URL directly in Google Chrome, Inspector says </p> <blockquote> <p>Resource interpreted as Document but transferred with MIME type application/json.</p> </blockquote> <p>also tried Firefox and it gets as a file to download.</p> <p>b) When I use <code>jQuery.ajax</code> works only if I don't pass the dataType argument, if I put for example dataType:'json' then I get this error on jquery.js file</p> <blockquote> <p>Uncaught SyntaxError: Unexpected token :</p> </blockquote> <p>What am I doing bad?</p> <p>I am using jquery 1.5.2 and Django Trunk (r15915 updated about two weeks ago) and calling only same domain urls.</p> <p>EDIT: jQuery.getJSON does not work, but worked on jquery 1.4.2. Looking firebug console on Request Headers says Content-Type: application/x-www-form-urlencode, this may be related to the problem.</p> <p>Thanks in advance</p> </div>

Django Ajax jQuery URL

<div class="post-text" itemprop="text"> <p>I have the following template file, where I am going to perform an <em>ajax request</em>. If I click on the <em>show link</em> in the template the jquery function gets executed and then I receive the following <strong>error message</strong> in the developer console of my browser: </p> <ul> <li><p>TypeError at /projects/djangobook/discussions/5/show/8</p></li> <li><p>'NoneType' object is not callable</p></li> </ul> <p><strong>Traceback:</strong></p> <p>File "/Users/sebastian/Developer/Zaumdo/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 115. response = callback(request, *callback_args, **callback_kwargs)</p> <p>File "/Users/sebastian/Developer/Zaumdo/lib/python2.7/site-packages/django/views/generic/base.py" in view 68. return self.dispatch(request, *args, **kwargs)</p> <p>File "/Users/sebastian/Developer/Zaumdo/lib/python2.7/site-packages/braces/views.py" in dispatch 107. request, *args, **kwargs)</p> <p>File "/Users/sebastian/Developer/Zaumdo/Zaumdo/core/mixins.py" in dispatch 49. return super(GroupAwareMixin, self).dispatch(request, *args, **kwargs)</p> <p>File "/Users/sebastian/Developer/Zaumdo/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch 86. return handler(request, *args, **kwargs)</p> <p>Exception Type: TypeError at /projects/djangobook/discussions/5/show/8</p> <p>Exception Value: 'NoneType' object is not callable</p> <p>Request information: GET: No GET data</p> <p>POST: name = u'sebastian'</p> <p>FILES: No FILES data</p> <p>COOKIES: csrftoken = 'fWD0OojhrpTLhuxtxb2NF96rVSnKGpWy' sessionid = 'fccuv36b538pqnulqyhbdsq7ihyrvjo5'</p> <p><strong>template.html</strong></p> <pre><code>{% for post in object_list %} {{ post.creator }} {{ post.created }} {{ post.body }} &lt;a href="{% groupurl post_answer group discussion_id=discussion.id pk=post.id %}"&gt;Answer&lt;/a&gt; &lt;a class="show_answers" href="{% groupurl post_show_answers group discussion_id=discussion.id post_id=post.id %}"&gt;Show&lt;/a&gt; {% endfor %} &lt;script type="text/javascript"&gt; $(".show_answers").click(function(e) { e.preventDefault(); var self = $(this); ajax_req = $.ajax({ url: self.attr("href"), type: "POST", data: {name: "sebastian"}, success: function(ctx) {console.log(ctx);} }); }); &lt;/script&gt; </code></pre> <p><strong>urls.py</strong></p> <pre><code>from django.conf.urls import patterns, url from discussions.views import DiscussionListView, DiscussionCreateView, DiscussionUpdateView, DiscussionDeleteView, PostListView, PostCreateView, PostAnswerView urlpatterns = patterns\ ( 'discussions.views', url(r'^$', DiscussionListView.as_view(), name='discussion_list'), url(r'^create/$', DiscussionCreateView.as_view(), name='discussion_create'), url(r'^update/(?P&lt;pk&gt;\d+)$', DiscussionUpdateView.as_view(), name='discussion_update'), url(r'^delete/(?P&lt;pk&gt;\d+)$', DiscussionDeleteView.as_view(), name='discussion_delete'), url(r'^(?P&lt;discussion_id&gt;\d+)/$', PostListView.as_view(), name='discussion'), url(r'^(?P&lt;pk&gt;\d+)/create/$', PostCreateView.as_view(), name='post_create'), url(r'^(?P&lt;discussion_id&gt;\d+)/answer/(?P&lt;pk&gt;\d+)', PostAnswerView.as_view(), name='post_answer'), url(r'^(?P&lt;discussion_id&gt;\d+)/show/(?P&lt;post_id&gt;\d+)', PostListView.as_view(), name='post_show_answers'), ) </code></pre> <p>In this view I would like to send an HttpResponse.</p> <p><strong>views.py</strong></p> <pre><code>class PostListView(LoginRequiredMixin, GroupAwareMixin, ListView): model = Post template_name = 'discussions/discussion.html' discussion = None post = None posts = None def get_queryset(self): # Get the discussions from the pk in the url self.discussion = get_object_or_404(Discussion, pk=self.kwargs['discussion_id']) # return HttpResponse(json.dumps("success"), mimetype="application/json") # Fetch all the root posts (depth=1) in the discussion self.posts = self.discussion.posts.filter(depth=depth) return self.posts def get_context_data(self, **kwargs): context = super(PostListView, self).get_context_data(**kwargs) context['discussion'] = self.discussion return context </code></pre> </div>

hue 3.9 hive 查询界面日志无法动态显示

进入hue hive查询界面,随便执行一个查询,无法动态显示日志,F12查看日志刷新请求返回: {"status": 2, "message": "database is locked"} 后台报错: [15/Mar/2016 00:07:37 -0700] api ERROR error in <function watch_query_refresh_json at 0x7fa8f0e5e9b0> Traceback (most recent call last): File "/usr/lib/hue/apps/beeswax/src/beeswax/api.py", line 54, in decorator return view_fn(request, *args, **kwargs) File "/usr/lib/hue/apps/beeswax/src/beeswax/api.py", line 180, in watch_query_refresh_json query_history.save_state(state) File "/usr/lib/hue/apps/beeswax/src/beeswax/models.py", line 243, in save_state self.save() File "/usr/lib/hue/apps/beeswax/src/beeswax/models.py", line 189, in save super(QueryHistory, self).save(*args, **kwargs) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 545, in save force_update=force_update, update_fields=update_fields) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 573, in save_base updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 635, in _save_table forced_update) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/base.py", line 679, in _do_update return filtered._update(values) > 0 File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/query.py", line 510, in _update return query.get_compiler(self.db).execute_sql(None) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/compiler.py", line 980, in execute_sql cursor = super(SQLUpdateCompiler, self).execute_sql(result_type) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/models/sql/compiler.py", line 786, in execute_sql cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute return self.cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/utils.py", line 99, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/util.py", line 53, in execute return self.cursor.execute(sql, params) File "/usr/lib/hue/build/env/lib/python2.6/site-packages/Django-1.6.10-py2.6.egg/django/db/backends/sqlite3/base.py", line 452, in execute return Database.Cursor.execute(self, query, params) **OperationalError: database is locked** 但是在历史记录里能查看到这次查询及结果。不知道什么原因,请大神指教

Django查询不匹配

<div class="post-text" itemprop="text"> <p>I have the following Django Model:</p> <pre><code>class State(models.Model): name = models.CharField(max_length=80,null=False) latitude = models.CharField(max_length=80,null=False) longitude = models.CharField(max_length=80,null=False) def __unicode__(self): return self.name </code></pre> <p>In my views.py file I've created the following method:</p> <pre><code>def getCoords(request): if request.is_ajax(): if request.method == 'POST': try: state = request.POST['state'] #receives the state from JS stateInstance = State.objects.get(name=state) stateLat = stateInstance.latitude stateLong = stateInstance.longitude data = {"lat" : stateLat, "long" : stateLong} except State.DoesNotExist: return HttpResponse("No record") return HttpResponse(simplejson.dumps(data)) #returns json </code></pre> <p>So I'm sending this method a param through ajax, let's say "California". The state variable gets the value (I have proved that) but the query doesn't get executed, it returns the query doesn't match message. I've tried with the following as well:</p> <pre><code> state = request.POST['state'] if state == 'California': return HttpResponse("Yes!") else: return HttpResponse(state) </code></pre> <p>When this snippet returns the state it displays California which means state's value is correct but the query is not executed properly. I don't know what's going on. Any thoughts?</p> </div>

python中URL地址用.format转换后出错

python中URL地址用.format转换后出错,提示JSONDecodeError("Expecting value", s, err.value) from None。 不转换的话没什么问题,url地址放在了address变量中(我用的是python3) ``` import urllib.request import ssl import json from cons import cons ssl._create_default_https_context = ssl._create_unverified_context station_list = {} for i in cons.split('@'): if i: temp_list = i.split('|') station_list[temp_list[1]] = temp_list[2] train_date = '2017-8-17' from_station = station_list['北京'] to_station = station_list['上海'] print(train_date, from_station, to_station) def get_list(): address = 'https://kyfw.12306.cn/otn/leftTicket/query?leftTicketDTO.train_date={0}' \ '&leftTicketDTO.from_station={1}' \ '&leftTicketDTO.to_station={2}&purpose_codes=ADULT'.format(train_date, from_station, to_station) print(address) url = urllib.request.Request(address) url.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)' ' Chrome/45.0.2454.101 Safari/537.36') html = urllib.request.urlopen(url).read() dit = json.loads(html) print(type(html)) print(type(dit)) return dit['data']['result'] # 车次3 # 出发时间8 # 到达时间9 # 历时 = 10 # 硬卧 =28 # 出发日期 13 for i in get_list(): temp_buy = i.split('|') if temp_buy == '无' or temp_buy == ' ': continue else: print(temp_buy) # buy break ``` cost.py中的代码如下 ``` cons = '@bji|北京|BJP|0@sha|上海|SHH|1@tji|天津|TJP|2@cqi|重庆|CQW|3' \ '@csh|长沙|CSQ|4@cch|长春|CCT|5@cdu|成都|CDW|6@fzh|福州|FZS|7' \ '@gzh|广州|GZQ|8@gya|贵阳|GIW|9@hht|呼和浩特|HHC|10' \ '@heb|哈尔滨|HBB|11@hfe|合肥|HFH|12@hzh|杭州|HZH|13' \ '@hko|海口|VUQ|14@jna|济南|JNK|15@kmi|昆明|KMM|16' \ '@lsa|拉萨|LSO|17@lzh|兰州|LZJ|18@nni|南宁|NNZ|19' \ '@nji|南京|NJH|20@nch|南昌|NCG|21@sya|沈阳|SYT|22' \ '@sjz|石家庄|SJP|23@tyu|太原|TYV|24@wlq|乌鲁木齐南|WMR|25' \ '@wha|武汉|WHN|26@xni|西宁|XNO|27@xan|西安|XAY|28' \ '@ych|银川|YIJ|29@zzh|郑州|ZZF|30@szh|深圳|SZQ|shenzhen|sz|31' \ '@xme|厦门|XMS|xiamen|xm|32' ```

在$ .ajax()中使用Django

<div class="post-text" itemprop="text"> <p>I am trying to do something simple with Django and Ajax.</p> <p>My goal is to make a kind of lobby website, where each client knows the names of everybody currently in the lobby.</p> <p>The way I'm doing it (bear with me even if it's the most awful method you've ever heard of) is to have the client send a message every second that says "I'm still here!". If the server doesn't here from a client for five seconds, that client is removed from the list of people in the lobby. I have this working.</p> <p>What I can't figure out is how to send the list of players names that I have in by Django view back to the client. I've been trying to use JsonResponse and then receiving that in the success function of the <code>$.ajax()</code> call, but I can't seem to get it to work.</p> <p>Here is my <code>$.ajax()</code> call:</p> <pre><code>$.ajax({ url: apiUpdateUrl, method: "post", data: { csrfmiddlewaretoken: Cookies.get("csrftoken") }, dataType: "json", success: function(data) { console.log(data.player_list) } }); </code></pre> <p>Here is my Django view:</p> <pre><code>def update(request): if Player.objects.filter(nickname=request.user.username).count() == 0: player = Player(nickname=request.user.username, time_joined=datetime.datetime.now()) player.save() else: player = Player.objects.get(nickname=request.user.username) player.save() curr_time = datetime.datetime.now() for player in Player.objects.all(): if (curr_time - player.last_update).total_seconds() &gt;= 5: Player.objects.filter(pk=player.pk).delete() player_list = [p.nickname for p in Player.objects.all()] print(player_list) return JsonResponse({"player_list": player_list}) </code></pre> </div>

python/pycharm安装requests时错误怎么办?

![图片说明](https://img-ask.csdn.net/upload/202003/21/1584776828_633367.png)![图片说明](https://img-ask.csdn.net/upload/202003/21/1584776831_248826.png) ![图片说明](https://img-ask.csdn.net/upload/202003/21/1584776852_747645.png) 求大佬帮忙!

Django / Ajax获取请求

<div class="post-text" itemprop="text"> <p>I'm trying to implement client/server communication using Django and Ajax and I'm having problem with Ajax request.</p> <p>Here is my view:</p> <pre><code>from django.http import HttpResponse from rest_framework.renderers import JSONRenderer from rest_framework.parsers import JSONParser from taskmanager.models import Task from taskmanager.serializers import TaskSerializer class JSONResponse(HttpResponse): def __init__(self, data, **kwargs): content = JSONRenderer().render(data) kwargs['content_type'] = 'application/json' super(JSONResponse, self).__init__(content, **kwargs) def task_list(request): if request.method == 'GET': tasks = Task.objects.all() serializer = TaskSerializer(tasks, many=True) return JSONResponse(serializer.data) </code></pre> <p>And my jquery code:</p> <pre><code>$(document).ready(function(){ $("button").click(function(){ $.ajax({ type: "get", url: "http://127.0.0.1:8000/", dataType: "json", success: function(data){ alert(data[0]["title"]); }, error: function(){ alert("error"); } }); }); }); </code></pre> <p>Every time server returns status 200 OK, but the error function is executed. When I visit that url directly in browser I get valid json output. Even more, if I put that output in a file and reference it in ajax call url it works as intended.</p> <p>P.S. Sorry for my English.</p> <p>UPDATE: Also, when I view response details in FireBug it has no response body. </p> <p>Response headers:</p> <pre><code>Server:WSGIServer/0.1 Python/2.7.3 Date:Fri, 10 May 2013 07:56:23 GMT Content-Type:application/json </code></pre> <p>UPDATE: changed AJAX url to: <code>"http://127.0.0.1:8000/?callback=?"</code> and now I get response body: <code>[{"id": "518a92147c2fce152b081878", "title": "New task"}, {"id": "518a905e7c2fce1516b8f9dc", "title": "Save the galaxy"}, {"id": "518a904e7c2fce1516b8f9da", "title": "Do a barrel roll"}]</code>, status -- 200 and error -- parsererror.</p> </div>

'str' object has no attribute 'get'咋解决?

本人学医,凭兴趣自学python,真心不易,现在遇到一个问题:在写一个简单的注册提交页面,是想通过class将数据存储到本地的txt文件,在输入username和password,submit到register/add时,但遇到了下面的问题: ![图片说明](https://img-ask.csdn.net/upload/201801/27/1517032413_303388.jpg) 请各位大神帮助看是什么问题。 下面是源代码,看看还有没有其他什么问题。谢谢! app.py ``` from flask import ( Flask, render_template, request, redirect, ) from Models import (Users, Requirements) import time import os app = Flask(__name__) @app.route('/', methods=['GET']) def index(): return render_template('/index.html') @app.route('/login') def login(): return render_template('/login.html') @app.route('/register') def register(): return render_template('/register.html') @app.route('/register/add', methods=['POST']) def register_add(): if request.method == 'POST': form = request.form print('打印', form) u = Users.new(form) u.save() return redirect('/login') @app.route('/post', methods=['GET']) def post_message(): return render_template('/post.html') @app.route('/post/add', methods=['POST']) def post_add(): if request.method == 'POST': form = request.form u = Requirements(form) u = Requirements.new(form) u.save() return redirect('/post') if __name__ == '__main__': config = dict( debug=True, host='0.0.0.0', port=2000, ) app.run(**config) ``` Model.py ``` from random import Random import json import os def save(data, path): m = json.dumps(data, ensure_ascii=False) # path = os.path.dirname(__file__) with open(path, 'a+') as f: f.read() f.write(m + '\n') f.close() def load(path): with open(path, 'r', encoding='utf-8') as f: s = f.read() m = json.dumps(s, ensure_ascii=False) print('加载', type(m), m) t = json.loads(m) print('加载', type(t), t) return t def random_str(randomlength=16): s = '' chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789' length = len(chars) - 1 random = Random() for i in range(randomlength): s += chars[random.randint(0, length)] return s class Model(object): @classmethod def db_path(cls): root = os.path.dirname(__file__) classname = cls.__name__ path = '{}/data/{}.txt'.format(root, classname) return path @classmethod def all(cls): """ all 方法(类里面的函数叫方法)使用 load 函数得到所有的 models """ path = cls.db_path() models = load(path) ms = [cls.new(m) for m in models] return ms @classmethod def new(cls, form): m = cls(form) return m def save(self): models = self.all() path = self.db_path() l = [m.__dict__ for m in models] save(l, path) class Users(Model): def __init__(self, form): self.id = random_str() self.username = form.get('username', '') self.password = form.get('password', '') class Requirements(Model): def __init__(self, form): self.id = form.get('id', None) self.province = form.get('province', '') self.city = form.get('city', '') self.post_content = form.get('post_content', '') self.contact_requirement_method = form.get('contact_requirement_method', '') ``` 最后搞定了,采取了下面这种方式,然后有修改了Model部分内容 ``` if request.method == 'POST': formdata = request.form form = formdata.to_dict() u = Users.new(form) u.save() ```

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

Linux面试题(2020最新版)

文章目录Linux 概述什么是LinuxUnix和Linux有什么区别?什么是 Linux 内核?Linux的基本组件是什么?Linux 的体系结构BASH和DOS之间的基本区别是什么?Linux 开机启动过程?Linux系统缺省的运行级别?Linux 使用的进程间通信方式?Linux 有哪些系统日志文件?Linux系统安装多个桌面环境有帮助吗?什么是交换空间?什么是root帐户什么是LILO?什...

将一个接口响应时间从2s优化到 200ms以内的一个案例

一、背景 在开发联调阶段发现一个接口的响应时间特别长,经常超时,囧… 本文讲讲是如何定位到性能瓶颈以及修改的思路,将该接口从 2 s 左右优化到 200ms 以内 。 二、步骤 2.1 定位 定位性能瓶颈有两个思路,一个是通过工具去监控,一个是通过经验去猜想。 2.1.1 工具监控 就工具而言,推荐使用 arthas ,用到的是 trace 命令 具体安装步骤很简单,大家自行研究。 我的使用步骤是...

学历低,无法胜任工作,大佬告诉你应该怎么做

微信上收到一位读者小涛的留言,大致的意思是自己只有高中学历,经过培训后找到了一份工作,但很难胜任,考虑要不要辞职找一份他能力可以胜任的实习工作。下面是他留言的一部分内容: 二哥,我是 2016 年高中毕业的,考上了大学但没去成,主要是因为当时家里经济条件不太允许。 打工了三年后想学一门技术,就去培训了。培训的学校比较垃圾,现在非常后悔没去正规一点的机构培训。 去年 11 月份来北京找到了一份工...

JVM内存结构和Java内存模型别再傻傻分不清了

JVM内存结构和Java内存模型都是面试的热点问题,名字看感觉都差不多,网上有些博客也都把这两个概念混着用,实际上他们之间差别还是挺大的。 通俗点说,JVM内存结构是与JVM的内部存储结构相关,而Java内存模型是与多线程编程相关,本文针对这两个总是被混用的概念展开讲解。 JVM内存结构 JVM构成 说到JVM内存结构,就不会只是说内存结构的5个分区,而是会延展到整个JVM相关的问题,所以先了解下

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

Google 与微软的浏览器之争

浏览器再现“神仙打架”。整理 | 屠敏头图 | CSDN 下载自东方 IC出品 | CSDN(ID:CSDNnews)从 IE 到 Chrome,再从 Chrome 到 Edge,微软与...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

搜狗输入法也在挑战国人的智商!

故事总是一个接着一个到来...上周写完《鲁大师已经彻底沦为一款垃圾流氓软件!》这篇文章之后,鲁大师的市场工作人员就找到了我,希望把这篇文章删除掉。经过一番沟通我先把这篇文章从公号中删除了...

85后蒋凡:28岁实现财务自由、34岁成为阿里万亿电商帝国双掌门,他的人生底层逻辑是什么?...

蒋凡是何许人也? 2017年12月27日,在入职4年时间里,蒋凡开挂般坐上了淘宝总裁位置。 为此,时任阿里CEO张勇在任命书中力赞: 蒋凡加入阿里,始终保持创业者的冲劲,有敏锐的...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

什么时候跳槽,为什么离职,你想好了么?

都是出来打工的,多为自己着想

程序员为什么千万不要瞎努力?

本文作者用对比非常鲜明的两个开发团队的故事,讲解了敏捷开发之道 —— 如果你的团队缺乏统一标准的环境,那么即使勤劳努力,不仅会极其耗时而且成果甚微,使用...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

立即提问
相关内容推荐