python 提示 :OverflowError: Python int too large to convert to C long

Posted XuMou

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 提示 :OverflowError: Python int too large to convert to C long相关的知识,希望对你有一定的参考价值。

一次在使用orm进行联表查询的时候,出现   Python int too large to convert to C long 的问题:

在分析错误之后,在错误最后面提示中有:

  File "F:\\python\\python3.6\\lib\\sqlite3\\dbapi2.py", line 64, in convert_date
    return datetime.date(*map(int, val.split(b"-")))

在查看我的model.py文件的时候我的模型定义是:

from django.db import models


# Create your models here.

class Book(models.Model):
    nid = models.AutoField(primary_key=True)
    title = models.CharField(max_length=64)
    publishDate = models.DateField()
    price = models.DecimalField(max_digits=5, decimal_places=2)

    publish = models.ForeignKey(to="Publish", to_field="nid", on_delete=models.CASCADE)

    authors = models.ManyToManyField(to="Author")


class Author(models.Model):
    nid = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    age = models.IntegerField()
    # 作者和作者信息一对一
    AuthorDetail=models.OneToOneField(to="AuthorDetail",on_delete=models.CASCADE)


class AuthorDetail(models.Model):
    nid = models.AutoField(primary_key=True)
    # birthday = models.DateField()  # 特别是这一行进行注视后,就不会再提示 Python int too large to convert to C long  了
  # 或则将此行改为
  birthday = models.DateTimeField()
   tetephone = models.BigIntegerField()
    addr = models.CharField(max_length=64)


class Publish(models.Model):
    nid = models.AutoField(primary_key=True)
    name = models.CharField(max_length=32)
    city = models.CharField(max_length=32)
    email = models.EmailField()

以上是关于python 提示 :OverflowError: Python int too large to convert to C long的主要内容,如果未能解决你的问题,请参考以下文章

如何修复 OverflowError:int64 加法中的溢出

在 Pyside 中,为啥在处理信号后发出大于 0x7FFFFFFF 的整数会导致“OverflowError”?

如何在没有OverflowError的情况下等待键盘输入

Pysftp "cd" 对 AIX 服务器失败,并出现 "OverflowError: mode out of range" 错误

MIMIC-III 数据集处理 | OverflowError: Overflow in int64 addition 解决方法

from py2neo.Graph import Graph报错:OverflowError: mktime argument out of range