print number
Posted tnyleyon
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了print number相关的知识,希望对你有一定的参考价值。
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: printsquare
Description :
Author : Administrator
date: 2018/9/8 0008
-------------------------------------------------
"""
def print_square(n):
"""
5(-2,-1,0,1,2)-->range(-2,3)
:param n:
:return:
"""
assert isinstance(n, int), "n must be int"
e = -n // 2
if n == 1:
print("* * " * 2)
elif n == 2:
print("* " * 2, "*")
print("*", " " * 2, "*")
print("* " * 2, "*")
else:
for i in range(e, n + e + 1):
if i == e or i == n + e:
print("* " * (n + 1))
else:
print("* " + " " * (n - 1) + "*")
# print_square(2)
def print_number(x):
"""
接受一个数字字符串
:rtype: True
"""
w = int("1" + (len(int(x).__str__()) - 1) * "0")
x = int(x)
flag = False
while w:
t = x // w
if flag:
print(t)
else:
if t:
print(t)
flag = True
x %= w
w //= 10
return True
# noinspection PyTypeChecker
print_number("0054321")
以上是关于print number的主要内容,如果未能解决你的问题,请参考以下文章