Loading... [配套 jupyter 文件 ipynb http://pan.a152.top/s/7vwscbb1](http://pan.a152.top/s/7vwscbb1 "http://pan.a152.top/s/7vwscbb1") ## 求水仙花数 ## 条件 : 1. 三位数 2. $$ \begin{equation}\begin{split} bai^3+shi^3+ge^3 = number \end{split}\end{equation} $$  ```python for i in range(100,1000): ge = i%10 shi = i//10%10 bai = i//100 if i == ge**3+shi**3+bai**3 : print(i) ``` ### 输出结果如下 ```python 153 370 371 407 ``` --- ## 身份证信息提取 xxxxxx xxxx(年) xx(月) xx(日) xxx(性别) x  ```python id = str(input(["请输入身份证号码:"])) year = id[6:10] month = id[10:12] day = id[12:14] sex = int(id[-2]) #记得需要int一下 sex = sex%2 print(year) print(month) print(day) if sex == 0: print("女") else: print("男") ``` ### 输出结果如下 ```python ['请输入身份证号码:']333333200504151110 2005 04 15 男 ``` --- ## 拓展 除此之外,你会发现还有许许多多的问题 比如不小心输入错了身份证号码的位数啊什么的,就会造成了一些报错,这时候我们可以用try啊之类的来避免,当然,你可以按照自己的需要进行后续的更改! 在下提出了几个问题, 1.更加漂亮的表达方式 例子: $$ \begin{equation}\begin{split} 153 = 1^3+5^3+3^3 \\ 370 = 3^3+7^3+0^3 \\ 371 = 3^3+7^3+1^3 \\ 这样以此类推 \end{split}\end{equation} $$ 2.更加完美的身份证提取程序 Last modification:August 26, 2021 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 如果觉得我的内容对你有用,请随意赞赏