简体   繁体   English

如何检查 x 是否多于或少于七个整数?

[英]How do I check if x has more or less than seven integers?

x = []
y = int(input("Hello, please enter your date of birth in this format: DDMMYYYY"))
x.append(y)
b = len.x()
if b > 7:
    input("Please enter your date of birth correctly in the above format")
elif b < 7:
    input("Please enter your date of birth correctly in the above format")

At the moment I'm getting this error:目前我收到此错误:

b = len.x() b = len.x()

AttributeError: 'builtin_function_or_method' object has no attribute 'x' AttributeError: 'builtin_function_or_method' 对象没有属性 'x'

Sorry, I'm quite new to python, thanks for all the help!抱歉,我对 python 还很陌生,谢谢大家的帮助!

You can checkout the solution given in the below thread if you are dealing with date and time.如果您正在处理日期和时间,您可以查看以下线程中给出的解决方案。

Getting input date from the user in python using datetime.datetime 在 python 中使用 datetime.datetime 从用户获取输入日期

Python'a len() is a function . Python'a len()是一个函数 It does not work like you think it does.它不像你想象的那样工作。 What you doing is incorrect.你这样做是不正确的。 Instead of this:取而代之的是:

b = len.x()

Do this:做这个:

b = len(str(x))

You seem to be confused about the len() function.您似乎对len()函数感到困惑。 I suggest you read the Python documentation about it.我建议您阅读有关它的Python 文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找到小于x的最大整数? - How do I find the largest integer less than x? 如何检查列表中大于或小于var整数 - How to check a list for greater or less than var integers 查找小于或等于用户使用循环输入的数字的素数。 我怎么做? - Find prime numbers less than or equal to the number the user has entered with loops. How do I do that? 如何返回 DataFrame 的行,其中每个大陆的每个国家/地区的人口都少于 100? - How do I return the rows of DataFrame where every Country in each Continent has a Population of less of than 100? 我如何做大于/小于使用 MongoDB? - How do I do greater than/less than using MongoDB? 如何在大熊猫中合并多个csv的列而不使用picking_x或_y,而是选择具有信息的列 - How do I merge more than one column for csv's in pandas without picking_x or _y but instead picking the one that has the information 我如何找到所有可能的方法,我可以将一个数组安装到 4 个插槽中,并且数组可能有更多/少于 4 个数字? - How do I find all possible ways I can fit an array to 4 slots with the possibility of the array having more/less than 4 numbers? 如何检查任何行是否大于 x 并返回列名? - How to check if any row is more than x and return name of column? 如何检索不超过X天的所有RSS条目 - How do I retrieve all RSS entries that are no more than X days old 如何编写 Python 脚本,以便以超过 2 倍的播放速度循环运行浏览器视频? - How do I code a Python script for running a browser video in loop at playback speed more than 2x?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM