django 提交表单后 函数解析参数报错TypeError: not nonetype

这是views里的代码

from django.http import HttpResponse
from django.shortcuts import render
from .models import Item
# Create your views here.
def get_html(req):
    return render(req,"item.html")
def create_item(req):
    #解析参数
    params = req.POST
    name = params.get("i_name")
    barcode = params.get("i_barcode")
    cate_id = int(params.get("cate_id"))
    #创建数据
    item = Item.objects.create(
        name = name,
        barcode = barcode,
        category_id=cate_id
    )
    return HttpResponse("创建成功啦{}".format(item.name))

这是models的代码

from django.db import models

# Create your models here.
class Category(models.Model):
    name = models.CharField(
        max_length=30,
        verbose_name="分类名",
        db_column="cate_name" #改数据表字段的名字
    )
    cate_num = models.CharField(
        max_length=20,
        null=True,
        verbose_name="分类的编号"
    )
    create_time = models.DateTimeField(
        auto_now_add=True,
        verbose_name="创建时间"
    )
    update_time = models.DateTimeField(
        auto_now=True,
        verbose_name="修改时间"
    )
    class Meta:
        # 改数据表的名字
        db_table = "category"
    # PEP8


class Item(models.Model):
    name = models.CharField(
        max_length=40,
        verbose_name="商品名字"
    )

    barcode = models.CharField(
        max_length=13,
        verbose_name="条码",
        null=True
    )
    category = models.ForeignKey(
        Category,
        db_index=True
    )

图片说明图片说明

2个回答

你使用的对象没有定义,检查一下是否有拼写错误。还有可能的原因是没有import被调用的模块而使用了模块的功能。你可以尝试一下print type(XXX) 应该就能发现问题了。

weixin_43363700
我的珊珊 谢谢您的回答,但是这两种情况经过检查已经排除了,我看了一些相似的问题,不知道是不是外键的原因,网上这类型的问题很少很少,我更新了models的代码,您方便帮我看下吗,models的表都更新到数据库了
7 个月之前 回复

解决了吗??明显的问题是你没有获取到参数值,cate_id = int(params.get("cate_id")),你看看前台有没有传cate_id这个参数值,如果是form表单,那就看name属性有没有cate_id

hallen41
hallen41 回复我的珊珊: 结贴吧,哈哈
5 个月之前 回复
weixin_43363700
我的珊珊 解决了,谢谢啦
6 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
TypeError: 'NoneType' object is not subscriptable
不知道咋了?求助[img=https://img-bbs.csdn.net/upload/201804/05/1522907557_991223.jpg][/img]
python+selenium 报错:TypeError: 'NoneType' object is not subscriptable
baidu1.pyrnrn#coding=utf-8rnfrom selenium import webdriverrnrndriver = webdriver.Firefox()rndriver.get("http://www.baidu.com")rnrnsize=driver.find_element_by_id('kw').sizernprint ("size")rnrntext=driver.find_element_by_id("cp").textrnprint ("text")rnrnattribute=driver.find_element_by_id("kw").get_attribute('type')rnprint ("attribute")rnrnresult=driver.find_element_by_id("kw").is_displayed()rnprint ("result")rnrndriver.quit()rnrnrnPython 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32rnType "copyright", "credits" or "license()" for more information.rn>>> rn RESTART: C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\baidu1.py rnTraceback (most recent call last):rn File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\baidu1.py", line 7, in rn size=driver.find_element_by_id('kw').sizern File "C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webelement.py", line 519, in sizern new_size = "height": size["height"],rnTypeError: 'NoneType' object is not subscriptablern>>>
TypeError: 'NoneType' object is not iterable
部分代码如下,运行后总是提示 Traceback (most recent call last):n File "E:\project1\src\neirongxiangguanxing.py", line 156, in n setstatus = set(statuslist)nTypeError: 'NoneType' object is not iterable,什么原因?有没有大神指导下?非常感谢n```n for status in allstatus:n dictvalue = []n words = jieba.cut(status.gettext()[:-1])n for word in words:n if word not in stopwordslist:n dictvalue.append(word)n allstatusdict[status.getid()] = dictvaluenn allcomments = []n allcomments = readallcomments(inputfile)n for comment in allcomments:n statuslist = allstatusdict.get(comment.getid())n setstatus = set(statuslist)n dictcomment = []n words = jieba.cut(comment.gettext()[:-1])n for word in words:n if word not in stopwordslist:n dictcomment.append(word)n setcomment = set(dictcomment)n```nn
TypeError: 'NoneType' object is not subscriptable python3写的代码
报错在图片里面,不清楚具体怎么改。[img=https://img-bbs.csdn.net/upload/201710/09/1507512052_96666.png][/img]rn[code=python]rn# -*- coding: utf-8 -*-rn"""rnCreated on Sun Oct 8 20:20:44 2017rnrn@author: llrn"""rnrnimport numpy as nprnrndef findMax1(array):rn if len(array)<1:#len(array)得到列表长度rn return [-1,-1]rn index = 1rn unit = array[index]rn for j in range(1,len(array)):rn if array[j] > array[index+1] and array[j] > array[index-1]:#if的含多条件语句的写法rn unit = array[j]rn return [unit,j]#返回的是一个列表类型,最大值和它的坐标1rnrndef getMax1(matrix, column_Num):rn array = [col[column_Num] for col in matrix]#将找到的列循环遍历后放到列表中rn return findMax1(array)rn rndef getPeak(matrix, leftCol, rightCol):rn if rightCol <= leftCol:rn r = getMax1(matrix,leftCol)rn r.append(leftCol)rn mid = int((leftCol + rightCol) / 2)rn unit = getMax1(matrix, mid)#返回的变量名要和接收传参的名字一样rnrn rightElem = getMax1(matrix, mid+1)rn if leftCol == rightCol - 1:rn leftElem = unitrn if leftElem[0] > rightElem[0]:rn r = leftElemrn r.append(mid)rn else:rn r = rightElemrn r.append(mid+1)rn return rrnrn leftElem = getMax1(matrix, mid-1)rn if unit[0] >= leftElem[0] and unit[0] >= rightElem[0]:rn unit.append(mid)rn return unitrn if unit[0] < leftElem[0]:rn return getPeak(matrix,leftCol,mid-1)rn return getPeak(matrix,mid+1,rightCol)rnrnrnrnprint("please input row:")rnn = int(input())rnprint("please input column:")rnm = int(input())rnmatrix = np.random.randint(100,999,size=[n,m])rnprint(matrix)rnrnresult = getPeak(matrix,0,len(matrix[0])-1)rnrnprint(result)rnrn[/code]
Django之提交表单与前后端交互
Django之META与前后端交互 1 提交表单之GET 前端提交数据与发送 1)提交表单数据 2)提交JSON数据 后端的数据接收与响应 1)接收GET请求数据 2)接收POST请求数据 3)响应请求 GET 请求过程 前端通过ajax发起GET请求,json格式...
Django第七篇-----如何提交表单
目录 如何获取url的信息 其他可用来反爬的信息 一个简单的表单处理 简单的验证 第一个表单类 在视图中使用表单对象 改变字段的渲染方式 设定最大长度 设定初始值 自定义验证规则 指定标注 如何获取url的信息 HttpRequest 对象中有一些关于当前所请求 URL 的信息 其他可用来反爬的信息 request.META 的值是一个 Python 字典,包含请...
Django在提交表单时的表单验证
1、首先在app里面新建一个forms文件2  引入所需要的包from django import forms3.创建一个类 这个类是继承自forms.Form4.下面就已一个email类为例子
Django里面request提交表单
我们在提交表单时,会通过request.method=='GET'或者是request.method=='POST'来理解当是在网址栏直接访问网址时,就是GET方法提交网址.当是在页面提交表单时就是POST方法提交....
python——导入excel报错( TypeError)
经过一段时间折腾linux和python环境安装,开始初次学习python 代码如下: 报错如下: 代码与原代码完全一致,暂时没有找到原因
extjs4.0 报错TypeError: container is null
之前好好的今天突然报了这个错误 extjs 4.0 报错TypeError: container is null 这是什么原因?
python+requests+xpath爬取贴吧评论总是报错NoneType
本人新人,刚学爬虫。看了个例子仿照着写了个爬取贴吧回复的,但是运行总是报错无类型......我估计是我的xpath定位问题,但我不知道该怎么改,或者是其他地方错了。哪位大神帮忙指导下!!谢谢!!以下是代码rnimport requestsrnfrom lxml import etreernimport jsonrnimport timernfrom requests.exceptions import RequestExceptionrnfrom pymongo import MongoClientrnrnclient=MongoClient()rndb=client.tieba #连接tieba数据库,没有则自动创建rnmy_set=db.comment #使用comment集合,没有则自动创建rnrndef get_html(url):rn try:rn response = requests.get(url)rn if response.status_code == 200:rn return response.textrn else:rn return Nonern except RequestException:rn return Nonernrndef parse_html(html):rn selector=etree.HTML(html)rn data=selector.xpath('//div[@class="l_post l_post_bright j_l_post clearfix "]')rn for each in data:rn rs=each.xpath('@data-field')[0]rn rs=json.loads(rs)rn author=rs.get('author').get('user_name')rn author_id=rs.get('content').get('post_id')rn content=each.xpath('div/div/cc/div[@id="post_content_%s"]/text()'% author_id)[0].strip()rn date=rs.get('content').get('date')rn yield rn 'author':author,rn 'content':content,rn 'date':datern rnrndef save_to_txt(result):rn print('正在存储:',result)rn with open('tieba.txt','a',encoding='utf-8') as f:rn f.write('回帖作者:'+result['author']+'\n')rn f.write('回帖内容:' + result['content'] + '\n')rn f.write('回帖时间:' + result['date'] + '\n')rn f.write('\n')rnrndef main(url):rn html=get_html(url)rn if html:rn for result in parse_html(html):rn save_to_txt(result)rnrnif __name__=='__main__':rn for i in range(1,21):rn url = 'https://tieba.baidu.com/p/5501399200?fid=59099&pn='+str(i)rn print('正在爬取第%s页'% str(i))rn main(url)rn time.sleep(10)rnrn爬取的网址是https://tieba.baidu.com/p/5501399200?fid=59099&pn=1
关于提交表单后 地址栏参数的编码问题?
关于提交表单后 地址栏参数的编码问题?rnrn[url]http://www.baidu.com/s?wd=%D3%CE%CF%C0&cl=3[/url]rnrnrn其中%D3%CE%CF%C0 代表关键字 “游侠”rnrnrn一般在某个页面上假如为[b]A页[/b]我做如下链接 [url]http://www.baidu.com/s?wd=[/url]游侠&cl=3rnrn提交表单后 百度也能搜索rnrn我的问题是 部分网站 只能接受 [url]http://www.baidu.com/s?wd=%D3%CE%CF%C0&cl&cl=3[/url]即编码后的查询rnrn那我们在[b]A页[/b]上该 如何处理“游侠”该字段 ,使“游侠”自动编码为 “%D3%CE%CF%C0&cl&cl” rnrn即查询变为[url]http://www.baidu.com/s?wd=%D3%CE%CF%C0&cl&cl=3[/url]
Django报错
报错  django.db.utils.InternalError: (1067, &quot;Invalid default value for 'id'&quot;)   File &quot;E:\Python3.7.1\lib\site-packages\django\core\management\__init__.py&quot;, line 381, in execute_from_command_line     ut...
django报错
1、首先是报出这个数据库错误 django.db.utils.OperationalError: no such table: watering1_normaluser 2、查了一下可以在cmd运行这两个代码 (1)python manage.py makemigrations 这是呈现的结果 Migrations for 'watering1':   watering1\migrati...
解析main()函数的参数-----getopt()
#include &amp;amp;lt;unistd.h&amp;amp;gt; int getopt(int argc, char * const argv[],const char *optstring); extern char *optarg; extern int optind, opterr, optopt; 描述:该函数用于解析命令行参数。 如果argv的一个元素以'-'(且不是'-'或'--')开头,那...
getopt()函数解析命令行选项参数
#include &lt;unistd.h&gt; extern char *optarg;//当前选项的参数指针 extern int optind;//下次再次调用getopt时,从optind存储的位置重新可是检查选项 extern int opterr;//当opterr = 0时,getopt不向stderr输出错误信息. exter...
为什么报错说我未捕获TypeError:未定义的函数??
[code=javascript]rnrnrnrn rn JavaScript简易日历rnrn rnrnrnrn rnrnrnrnrnrn rnrn rn 1 JANrn 2 FERrn 3 MARrn 4 APRrn 5 MAYrn 6 JUNrn 7 JULrn 8 AUGrn 9 SEPrn 10 OCTrn 11 NOVrn 12 DECrn rn rn rn 1月活动rn 快过年了,大家可以商量着去哪玩吧~rn rnrnrnrnrnrnrn[/code]rnrnrn[img=https://img-bbs.csdn.net/upload/201502/19/1424328855_652608.jpg][/img]rnrnrn为啥说我这段话错了,明明是从ul 里面获取li阿,真不知道哪写错了,求指点
django学习——通过ajax提交表单
以对博文的评论为例来讲表单的提交,我们希望达到的结果是: 1. 评论完后,可以直接看到自己的评论; 2. 如果评论不正确,比如评论字数超出规定范围,则给出错误提示。如果采用传统的提交表单做法,是可以完成的:templates<form active="{% url 'blog' blog.id %}" method="post" class="comment-form" > {% csr
PHP提交表单时报错
在编写的PHP代码中,涉及到$_POST全局变量,在运行时,出现提示“你所查找的网页要使用返回此页可能需要重复已进行的所有的操作,是否继续操作? ”点继续,出现空白网页,是怎么回事,是php配置文件的问题吗?rn
提交表单到数据库报错
项目提交数据到数据库存储报错,在PM_PROJECT_STEP表中加了BID_BOND_TIME字段也不行还是报错,该怎么解决啊?n[WARN,JDBCExceptionReporter,http-apr-8080-exec-9] SQL Error: 904, SQLState: 42000n[ERROR,JDBCExceptionReporter,http-apr-8080-exec-9] ORA-00904: "BID_BOND_TIME": 标识符无效nn[WARN,JDBCExceptionReporter,http-apr-8080-exec-9] SQL Error: 904, SQLState: 42000n[ERROR,JDBCExceptionReporter,http-apr-8080-exec-9] ORA-00904: "BID_BOND_TIME": 标识符无效nnorg.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; SQL [insert into PM_PROJECT_STEP (PM_PROJECT_ID, MC_MEMBER_ID, ENTRY_FEE, ENTRY_FEE_CH, ENTRY_FEE_BANK, ENTRY_FEE_NAME, ENTRY_FEE_ACCOUNT, POST_FEE, BID_BOND, STEP_ORDER, BID_BOND_CH, BID_BOND_BANK, BID_BOND_NAME, BID_BOND_ACCOUNT, BID_BOND_PHONE, BID_BOND_TIME, ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch updaten at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:635)n at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:794)n at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:665)n at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:755)n at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:724)n at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:475)n at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:270)n at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)n at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)n at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)n at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)n at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)n at com.wa.citgcbid.pm.service.PmProjectService$$EnhancerBySpringCGLIB$$6148982d.addUpdatePmProject()n at com.wa.citgcbid.pm.controller.PmProjectController.addUpdatePmProject(PmProjectController.java:464)n at sun.reflect.GeneratedMethodAccessor592.invoke(Unknown Source)n at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)n at java.lang.reflect.Method.invoke(Method.java:597)n at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)n at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)n at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)n at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)n at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:685)n at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)n at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:919)n at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:851)n at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)n at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:855)n at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)n at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)n at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)n at com.wa.framework.log.AccessLogFilter.doFilter(AccessLogFilter.java:120)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)n at com.wa.framework.web.SecurityFilter.doFilter(SecurityFilter.java:87)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)n at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)n at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:232)n at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:106)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)n at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)n at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)n at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)n at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)n at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)n at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)n at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)n at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)n at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)n at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)n at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)n at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)n at java.lang.Thread.run(Thread.java:662)nCaused by: org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch updaten at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)n at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)n at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)n at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)n at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)n at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)n at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2412)n at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2875)n at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)n at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)n at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)n at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)n at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)n at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)n at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)n at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)n at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)n at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:657)n ... 57 morenCaused by: java.sql.BatchUpdateException: ORA-00904: "BID_BOND_TIME": 标识符无效nn at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:17716)n at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:785)n at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeBatch(DruidPooledPreparedStatement.java:559)n at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)n at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)n ... 72 moren
EXT 提交表单 附带参数
[code=&quot;java&quot;] teaInfoForm.form.doAction('submit', { url: 'system/teaManage!readCrsByTeacherAndTerm', method:'post', success: function(response) { ...
安装Django后,创建项目失败,报错
安装Django后,创建项目的时候失败,报错:pkg_resources.DistributionNotFound: The 'pytz' distribution was not found and isrequired by Django 从报错可以看出是缺少pytz的信息 解决办法: 安装pytz: https://pypi.org/project/pytz/#files 之后再...
Django 中url函数中的name参数
url函数的name参数 urlpatterns = [ url(regex, views, kwargs=None, name=None) ] name:定义当前url的别名,允许在template中使用该别名来找到对应的url
【Python 学习笔记】文件写入时遇到 TypeError 报错
在一个简单的文件写入之后: fileOBJ = open("text1.txt","wb") fileOBJ.write("It is just a text.\n") fileOBJ.close() 我遇到了 TypeError 类型的报错: Traceback (most recent call last): File "text.py", line 5, in
Python报错TypeError 'object' is not callable 如何解决?
主程序mcc.py代码如下:rn[code=python]rn#coding=utf-8rnimport timernimport sysrnfrom utils.mailHelper import mailHelperrnfrom utils.excutor import executorrnfrom utils.configReader import configReaderrnreload(sys)rnsys.setdefaultencoding('utf-8')rnrnclass MCC(object):rn CONFIGPATH='_config.ini'rn KEY_COMMAND='Command'rn KEY_OPEN='Open'rn KEY_BOSS='Boss'rn KEY_TIMELIMIT='timelimit'rnrn def __init__(self):rn self.mailHelper=mailHelper()rn self.configReader=configReader(self.CONFIGPATH)rn commandDict=self.configReader.getDict(self.KEY_COMMAND)rn openDict=self.configReader.getDict(self.KEY_OPEN)rn self.timelimit=int(self.configReader.readConfig(self.KEY_BOSS,self.KEY_TIMELIMIT))rn self.excutor=executor(commandDict,openDict)rn self.toRun()rnrn def toRun(self):rn while True:rn self.run()rn time.sleep(self.timelimit)rnrn def run(self):rn mailBody=self.mailHelper.acceptMail()rn if mailBody:rn exe=self.mailHelper.analysisMail(mailBody)rn if exe:rn self.excutor.execute(exe)rnrnif __name__=='__main__':rn mcc=MCC()rn[/code]rn注:这是在网上学的一个通过收发邮件控制电脑完成简单命令的程序代码rn其他模块代码:rnconfigReader.pyrn[code=python]rn# coding=utf-8rnimport ConfigParserrnimport os,sysrnrnclass configReader(object):rn def __init__(self,configPath):rn configFile=os.path.join(sys.path[0],configPath)rn self.cReader=ConfigParser.ConfigParser()rn self.cReader.read(configFile)rnrn def readConfig(self,section,item):rn return self.cReader.get(section,item)rnrn def getDict(self,section):rn commandDict=rn items=self.cReader.items(section)rn for key,value in items:rn commandDict[key]=valuern return commandDictrn[/code]rnrnexcutor.pyrn[code=python]rn#coding=utf-8rnimport osrnimport mailHelperrnimport win32apirnfrom utils.mccLog import mccLogrnclass executor(object):rn def __init__(self,commandDict,openDict):rn self.mccLog=mccLog()rn self.mailHelper=mailHelper()rn self.commandDict=commandDictrn self.openDict=openDictrnrn def execute(self,exe):rn subject=exe['subject']rn self.mccLog.mccWriteLog(u'开始处理命令。')rn self.mailHelper.sendMail('pass','Slave')rn if subject in self.commandDict:rn self.mccLog.mccWriteLog(u'执行命令')rn try:rn command=self.commandDict[subject]rn os.system(command)rn self.mailHelper.sendMail('Success','Boss')rn self.mccLog.mccWriteLog(u'执行命令成功')rn except Exception,e:rn self.mccLog.mccError(u'执行命令失败'+str(e))rn self.mailHelper.sendMail('error','Boss',e)rn elif subject in self.openDict:rn self.mccLog.mccWriteLog(u'打开文件')rn try:rn openFile=self.openDict[subject]rn win32api.ShellExecute(0,'open',openFile,'','',1)rn self.mailHelper.sendMail('Success','Boss')rn self.mccLog.mccWriteLog(u'打开文件成功')rn except Exception,e:rn self.mccLog.mccError(u'打开文件失败'+str(e))rn self.mailHelper.sendMail('error','Boss',e)rn else:rn self.mailHelper.sendMail('error','boss','no such command')rn[/code]rnrnmailHelper.pyrn[code=python]rn#coding=utf-8rnfrom email.mime.text import MIMETextrnfrom configReader import configReaderrnfrom mccLog import mccLogrnimport poplibrnimport smtplibrnimport rernrnclass mailHelper(object):rn CONFIGPATH='_config.ini'rnrn def __init__(self):rn self.mccLog=mccLog()rn cfReader=configReader(self.CONFIGPATH)rn self.pophost=cfReader.readConfig('Slave','pophost')rn self.smtphost=cfReader.readConfig('Slave','smtphost')rn self.port=cfReader.readConfig('Slave','port')rn self.username=cfReader.readConfig('Slave','username')rn self.password=cfReader.readConfig('Slave','password')rn self.bossMail=cfReader.readConfig('Boss','mail')rn self.loginMail()rn self.configSlaveMail()rnrn def loginMail(self):rn self.mccLog.mccWriteLog(u'开始登录邮箱')rn try:rn self.pp=poplib.POP3_SSL(self.pophost)rn self.pp.set_debuglevel(0)rn self.pp.user(self.username)rn self.pp.pass_(self.password)rn self.pp.list()rn print u'登录成功!'rn self.mccLog.mccWriteLog(u'登录邮箱成功。')rn except Exception,e:rn print u'登录失败!'rn self.mccLog.mccError(u'登录邮箱失败'+str(e))rn exit()rnrn def acceptMail(self):rn self.mccLog.mccWriteLog(u'开始抓取邮件')rn try:rn ret=self.pp.list()rn mailBody=self.pp.retr(len(ret[1]))rn self.mccLog.mccWriteLog(u'抓取邮件成功')rn return mailBodyrn except Exception,e:rn self.mccLog.mccError(u'抓取邮件失败'+str(e))rn return Nonernrn def analysisMail(self,mailBody):rn self.mccLog.mccWriteLog(u'开始抓取subject和发件人')rn try:rn subject=re.search(" 'Subject:(.*?)',",str(mailBody[1]).decode('utf-8'),re.S).group(1)rn sender=re.search(" 'X-Sender:(.*?)',",str(mailBody[1]).decode('utf-8'),re.S).group(1)rn command='subject':subject,'sender':senderrn self.mccLog.mccWriteLog(u'抓取subject和发件人成功')rn return commandrn except Exception,e:rn self.mccLog.mccError(u'抓取subject和发件人失败'+str(e))rn return Nonernrn def configSlaveMail(self):rn self.mccLog.mccWriteLog(u'开始配置发件箱')rn try:rn self.handle=smtplib.SMTP(self.smtphost,self.port)rn self.handle.login(self.username,self.password)rn self.mccLog.mccWriteLog(u'发件箱配置成功')rn except Exception,e:rn self.mccLog.mccError(u'发件箱配置失败'+str(e))rn exit()rnrn def sendMail(self,subject,receiver,body='Success'):rn msg=MIMEText(body,'plain','utf-8')rn msg['Subject']=subjectrn msg['from']=self.usernamern self.mccLog.mccWriteLog(u'开始发送邮件'+'to'+receiver)rn if receiver =='Slave':rn try:rn self.handle.sendmail(self.username,self.username,msg.as_string())rn self.mccLog.mccWriteLog(u'发送邮件成功')rn return Truern except Exception,e:rn self.mccLog.mccError(u'发送邮件失败'+str(e))rn return Falsern elif receiver =='Boss':rn try:rn self.handle.sendmail(self.username,self.bossMail,msg.as_string())rn self.mccLog.mccWriteLog(u'发送邮件成功')rn except Exception,e:rn self.mccLog.mccError(u'发送邮件失败'+str(e))rn return Falsernrnif __name__ == '__main__':rn mail=mailHelper()rn body=mail.acceptMail()rn print bodyrn print mail.analysisMail(body)rn mail.sendMail('test','Boss')rn[/code]rnrnmccLog.pyrn[code=python]rn#coding:utf-8rnimport loggingrnfrom datetime import datetimernrnclass mccLog(object):rn def __init__(self):rn logging.basicConfig(level=logging.DEBUG,rn format='%(asctime)s %(levelname)s %(message)s',rn datefmt='%Y-%m-%d %H:%M:%S',rn filename=datetime.now().strftime("%Y%m%d%H%M%S")+'.log',rn filemode='a')rnrn def mccWriteLog(self,logContent):rn logging.info(logContent)rnrn def mccError(self,errorContent):rn logging.error(errorContent)rn[/code]rnrn以下是程序运行截图:rn[img=https://img-bbs.csdn.net/upload/201603/06/1457257492_846848.png][/img]rnrn求助~急~
Python 写文件报错TypeError的解决办法
处理上传的文件:        f1 = request.FILES['pic']        fname = '%s/%s' % (settings.MEDIA_ROOT, f1.name)        with open(fname, 'w') as pic:            for c in f1.chunks():                pic.write(c)测试报错:...
火狐17 报错 error:TypeError: Components.classes is undefined
之前可以用js获取上传本地文件路径的方法用不了了,求大神支招!!火狐以前的版本可以使用rnComponents.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); 这个获取到的,不知道新版本为什么不行了。
html报错:Uncaught TypeError的错误,求解答
html报错:Uncaught TypeError: $(...).dropdown is not a function,但是控制台没有报错,页面的下拉图标没有显示,这是哪里出错了呢?引用的js以前还是可以用的。
php函数base64_encode后的参数包含加号解析出错的解决方案
在进入主题之前我们先来看这样如下代码,test.php<?php $url = "test2.php?name=".base64_encode('用来做测试的字符串')."&age=23"; header("Location:$url"); test2.php <?php var_dump(base64_decode($_GET['name'])); die(); 访问http://
JqueryEasyui添加tab报错 :TypeError: $.data(...) is undefined
function re() rn //获得父级窗口中"id"为"back_tabs"的div,这个div是easyui的tabsrn var parent=window.parent.parent.document.getElementById("back_tabs");rn //将dom对象转换为jquery对象rn var t=$(parent); rn //判断如果已经存在 名为"回复"的标签,就选择,不存在就添加rn if (t.tabs('exists', "回复")) rn t.tabs('select', "回复")rn else rn t.tabs('add', rn title : "回复",rn href : 'mail/reply.jsp',rn closable : true,rn tools : [ rn iconCls : 'icon-mini-refresh',rn handler : function() rn rn ]rn );rn rn rnrnrn求解!!!
session丢失的情况下报错TypeError:document.body is null
web项目开发的时候,session丢失的时候,单击页面跳转时,会报错,rn谷歌浏览器没问题rn火狐浏览器弹出框TypeError:document.body is null,弹出框一闪而过rnIE浏览器![图片说明](https://img-ask.csdn.net/upload/201508/20/1440058676_380590.png)报错,弹出框一直存在不消失。点击确定后消失。rn后台程序没有报错。初步判定是session丢失的时候出现的错误。rn前台用的框架jquery和easyuirn问题可以重新。比如启动服务器,登陆后,重启服务器(消除session),在登陆页面单击跳转页面的按钮就会报错。或者通过等待session超时,也是重现问题
jsp页面Uncaught TypeError报错怎么解决呀
小弟我最近项目中碰到一个问题:rn我在一个系统中拷贝了别的项目的jsp文件,文件中用到的css等文件夹也一起拷贝过来了,但是用谷歌浏览器打开项目的时候,报一个错误:Uncaught TypeError: $(...).dialog is not a functionrn如图:rn[img=https://img-bbs.csdn.net/upload/201511/23/1448241568_734823.png][/img]rn请问下大家,应该怎么解决啊?或者哪里出问题了,帮小弟提供个思路。。不胜感激rn
'NoneType' object is not subscriptable
[code=python][/quote][/code]rnimport tushare as tsrnimport randomrnimport numpy as nprnimport pandas as pdrnimport xlwt rnstock_info = ts.get_stock_basics()rnl = list(stock_info.index)rnl.remove('600000')rnslice = random.sample(l, 100) rn rndata = pd.DataFrame()rndata1 = ts.get_hist_data('600000','2017-01-04','2018-03-16') rndata1 = data1['close']rndata1 = data1[::-1]rnrndata['600000']=data1rnrnrn rnfor i in range(0,len(slice)): rn datax = ts.get_hist_data(slice[i],'2017-01-04','2018-03-16')rn datax = datax['close']rn datax = datax[::-1]rn data[slice[i]] = datax rnrn小白想随机选取100支个股收盘数据存入data中,但是在执行过程中,一直出现datax是Nonetype的问题,每一次执行data存入的数据列数也不一样,也就是执行次数不一样。会不会是有些个股数据都是NAN 的问题?但是我在data里面看到 有些个股虽然都是NAN也可以读进data里面。rn希望大神可以帮助我一下!!!谢谢!!!
Python中NoneType问题
下面是我的程序,然后 里面报了给错误,哪位大神能帮我看看,我是 初学者,对这些还不是特别明白rn报的错误是这个样子的rnrnTraceback (most recent call last):rn File "E:/Neil/Code/Python/excel.py", line 19, in rn sum += itemrnTypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'rn1581rn0rnrn下面这个部分是代码,其中标红的位置,是编译器告诉的错误代码的位置rnrn#coding=utf-8rnfrom openpyxl import load_workbookrn#d = ws.cell(row = 3, column = 0)rnworkbook_ = load_workbook('e.xlsx') #导入工作表rnsheetnames =workbook_.get_sheet_names() #获得表单名字rnsheet = workbook_.get_sheet_by_name(sheetnames[0]) #从工作表中提取某一表单rnarrdata=[] #定义了一个列表rnsum = 0rnfor rowNum in range(4,30):rn for colNum in range(4,26):rn data = sheet.cell(row=rowNum,column=colNum).valuern arrdata.append(data)rn for item in arrdata:rn [color=#FF0000] sum += item[/color]rn print(sum)rn sum=0rn print(sum)rn arrdata = []
Python判断 NoneType数据类型
在用OpenCV读取图片时候图片破损了会报错,说Nonetype类型。 所以,我就想,条件过滤的时候用is not 或者 != 就可以过滤了,比如这样尝试的时候: type(answers[0].find_all("table")[0].string) is '''NoneType''' 结果我得到的是: False 接下来,我用==或者is 来判断也是False,我就猜想,难到不能用typ...
提交表单,为什么参数和参数之间有加号?
现在的url是这个样子的:Action.do?complex=5+&atmosphere=4+&service=3+&skill=3+&price=2+&content=aa。rn我想要的url结果是中间没有加号的,为什么出现加号,并且怎么解决?
用javascript函数提交表单??
现有一现成的函数—实现相关参数的删除操作,当点击按钮调用该函数,现在希望在函数中加入一段代码(form),当点击按钮时既实现相关参数的删除,又能将form中的数据发送出去。由于我不懂javascript,所以只有麻烦大家了。rnrn
PHP 提交表单后空白
检查了好多遍,并且也用var_dump,print_r post ,但是开始空白。rn表单代码rn[code=php][code=php]rnrnrnrnrn rn -.-rn rn rn rn rnrnrnrn 添加商品rn rn rn rn 商品名称rn rn rn rn 商品分类rn rn rn rn rn rn rn rn rn rn 商品等级rn rn rn rn 商品价格rn rn rn rn 商品描述rn rn rn rn rn rn 商品图像rn rn rn rn rn rn rn rn rnrnrnrn[/code][/code]rnrnPHP代码是rn[code=php]$uploadfile)rn thumb($path."/".$uploadfile['name'],"../../img/upload/proimg/img_50/".$uploadfile['name'],50,50);rn thumb($path."/".$uploadfile['name'],"../../img/upload/proimg/img_800/".$uploadfile['name'],500,500);rn rn rn $res=insert("product",$arr);rn $pid=getinsertid();rn if($res&&$pid)rn foreach($uploadFiles as $uploadFile)rn $arr1['product_id']=$pid;rn $arr1['path']=$uploadFile['name'];rn addAlbum($arr1);rn rn echo "修改数据成功! 继续添加|查看列表";rn elsern foreach($uploadfiles as $uploadfile)rn if(file_exists("../../img/upload/proimg/img_50/".$uploadfile['name']))rn unlink("../../img/upload/proimg/img_50/".$uploadfile['name']);rn rn if(file_exists("../../img/upload/proimg/img_800/".$uploadfile['name']))rn unlink("../../img/upload/proimg/img_800/".$uploadfile['name']);rn rn rn echo "修改数据失败! 继续添加";rn exit;rn rnrn[/code]$uploadfile)rn thumb($path."/".$uploadfile['name'],"../../img/upload/proimg/img_50/".$uploadfile['name'],50,50);rn thumb($path."/".$uploadfile['name'],"../../img/upload/proimg/img_800/".$uploadfile['name'],500,500);rn rn rn $res=insert("product",$arr);rn $pid=getinsertid();rn if($res&&$pid)rn foreach($uploadFiles as $uploadFile)rn $arr1['product_id']=$pid;rn $arr1['path']=$uploadFile['name'];rn addAlbum($arr1);rn rn echo "修改数据成功! 继续添加|查看列表";rn elsern foreach($uploadfiles as $uploadfile)rn if(file_exists("../../img/upload/proimg/img_50/".$uploadfile['name']))rn unlink("../../img/upload/proimg/img_50/".$uploadfile['name']);rn rn if(file_exists("../../img/upload/proimg/img_800/".$uploadfile['name']))rn unlink("../../img/upload/proimg/img_800/".$uploadfile['name']);rn rn rn echo "修改数据失败! 继续添加";rn exit;rn rnrnrnrn输出总是空白页,并且什么提示都没有。图片也没上传
查询提交表单后的问题
请问以下这段搜索的代码那边出了错?rn当我txtName没有填写内容,提交表单的时候,rnsql语句还是只执行最后一个sql语句,即select * from material order by Mat_id,rn而我要的效果是它应该执行第一条语句,即select * from material where Mat_name like '%$name%' and Mat_category in ($category)[code=HTML] rn 物料名称:rn rn 类别: rn rn 无rn 耗材rn 电脑rn 其他设备rn rn rnrn[/code][code=PHP]";rn if($_REQUEST['txtName']&&$_REQUEST['action']=="search") rn $name = $_REQUEST['txtName']; rn $category = $_REQUEST['txtCategory']; rn if($name == null)rn $sql = "select * from material where Mat_category in ($category) order by Mat_id";rn elsern $sql= "select * from material where Mat_name like '%$name%' and Mat_category in ($category)";rn elsern $sql = "select * from material order by Mat_id"; rn rn echo $sql;rn rn $page = page($db,$sql,5,$class);rn while($row=mysql_fetch_array($page[0]))rn?>[/code]
js 警告框后提交表单
[code=JScript]rn rn rnrnrnrnrn[/code]rn报错 说未找到对象form1
相关热词 c# 标准差 计算 c#siki第五季 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池