pythonはそれぞれ100千ビットを求めます

1149 ワード

pythonのいくつかのインスタンスでは、それぞれ1つの数の10,000ビットを求める必要があります.
eg.四桁の十百千位を求める
# -*- coding: UTF-8 -*-
if __name__=='__main__':
    x = int(raw_input('pls input a four number:
')) a = x / 1000 # b = x % 1000 / 100 # c = x % 100 / 10 # d = x %10 # print "original num is:
%d" %x print "after :
%d,%d,%d,%d" %(a,b,c,d)

eg.listに4桁のビット数をインポートし、stdoutを参照し、appendでリスト項目を追加
# -*- coding: UTF-8 -*-
from sys import stdout
if __name__=='__main__':
    x = int(raw_input('pls input a four number:
')) xx = [] a = x / 1000 # b = x % 1000 / 100 # c = x % 100 / 10 # d = x %10 # # xx.append(a) xx.append(b) xx.append(c) xx.append(d) print xx
簡略化コード:
# -*- coding: UTF-8 -*-
from sys import stdout
if __name__=='__main__':
    x = int(raw_input('pls input a four number:
')) xx = [] xx.append(x / 1000) xx.append(x % 1000 / 100) xx.append(x % 100 / 10) xx.append(x %10) print xx