Python 82
[Python 100] Python 100
(Python 2.0+)
#!/usr/bin/python
# -*- coding: UTF-8 -*-
if __name__ == '__main__':
n = 0
p = raw_input('input a octal number:\n')
for i in range(len(p)):
n = n * 8 + ord(p[i]) - ord('0')
print n
input a octal number: 122 82
[Python 100] Python 100
hello world
hel***[email protected]
Python3
#!/usr/bin/python3 def f8to10(num): print("8", num) l = str(num) length = len(l) sum = 0 for i in range(length): sum += 8 ** i * int(l[length-1-i]) print("10",sum) f8to10(122)hello world
hel***[email protected]
......
abc***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- if __name__ == '__main__': n = s = 0 L = [] n = raw_input(": \n") for i in range(len(n)): L.append(n[i]) L.reverse() for i in range(len(n)): s = s + int(L[i])*(8**i) print s......
abc***[email protected]
ray
117***[email protected]
#!/usr/bin/python # -*- coding: UTF-8 -*- def batoshi(num): count=0 j=len(num)-1 for each_ch in num: count+=pow(8,j)*int(each_ch) j-=1 return count print(batoshi('122'))ray
117***[email protected]
r49***[email protected]
#coding=utf-8 n=raw_input('') # lost=sum([int(n[-i])*8**(i-1) for i in range(1,len(n)+1)]) print '%s'%lostr49***[email protected]
shizi
ris***[email protected]
#coding=utf-8 n = reversed('122') s = 0 for idx,i in enumerate(n): s += int(i) * pow(8, idx) print (s)shizi
ris***[email protected]