在线 python 学习 平台
https://www.runoob.com/try/runcode.php?filename=HelloWorld&type=python3
https://www.runoob.com/python3/python3-tutorial.html
#!/usr/bin/python3
import os
a1=os.listdir('/usr')
print(a1)
print("Hello, World!")
>
from collections import OrderedDict
import pprint
def CPUinfo():
'''Return the info in /proc/cpuinfo
as a dirctionary in the follow format:
CPU_info['proc0']={...}
CPU_info['proc1']={...}
'''
CPUinfo=OrderedDict()
procinfo=OrderedDict()
nprocs = 0
with open('/proc/cpuinfo') as f:
for line in f:
if not line.strip():
#end of one processor
CPUinfo['proc%s' % nprocs]=procinfo
nprocs = nprocs+1
#Reset
procinfo=OrderedDict()
else:
if len(line.split(':')) == 2:
procinfo[line.split(':')[0].strip()] = line.split(':')[1].strip()
else:
procinfo[line.split(':')[0].strip()] = ''
return CPUinfo
CPUinfo = CPUinfo()
for processor in CPUinfo.keys():
print('CPUinfo[{0}]={1}'.format(processor,CPUinfo[processor]['model name']))