用python 來獲取當前電腦及python的資訊

2021-08-28 22:54:11 字數 926 閱讀 8922

# coding:utf-8

# 執行當前指令碼來獲取當前電腦及python的配置資訊。

import sys, platform

# 先看python。

a = sys.version_info

print

("當前python版本號是.."

.format

(a=a)

)ret =

# 當前作業系統

plat_form = platform.platform()if

"linux"

in plat_form:

ret[

"plat_form"]=

"linux"

elif

"windows"

in plat_form:

ret[

"plat_form"]=

"windows"

else

: ret[

'plat_form']=

"mac"

ret[

"version"

]= platform.version(

)ret[

'version_bit'

]= platform.architecture()[

0][0

:2]print

("當前系統是"

.format

(ret=ret)

)print

("作業系統版本號是"

.format

(ret=ret[

'version'

].split(

" ")[0

]))print

("作業系統"

.format

(ret=ret)

)

python獲取當前時間用GUI介面顯示

程式執行效果圖 有兩種方法,執行效果一樣 方法一 利用configure 或config 方法實現文字變化 方法一 利用configure 或config 方法實現文字變化 import tkinter import time def gettime 獲取當前時間並轉為字串 timestr time...

python 獲取當前目錄及子目錄

for root,dirs,files in os.walk r d test for file in files 獲取檔案所屬目錄 print root 獲取檔案路徑 print os.path.join root,file for root,dirs,files in os.walk r d t...

python 獲取當前時間

取得時間相關的資訊的話,要用到python time模組,python time模組裡面有很多非常好用的功能,你可以去官方 文件了解下,要取的當前時間的話,要取得當前時間的時間戳,時間戳好像是1970年到現在時間相隔的時間。你可以試下下面的方式來取得當前時間的時間戳 import time prin...