常用模塊之 time,datetime,random,os,sys

time與datetime模塊

先認識幾個python中關于時間的名詞:

時間戳(timestamp):通常來說,時間戳表示的是從1970年1月1日00:00:00開始按秒計算的偏移量。我們運行“type(time.time())”,返回的是float類型。1970年之前的日期無法以此表示,太遙遠的日期也不行,UNIX和Windows只支持到2038年,時間戳最適合做日期運算。

格式化的時間字符串(Format String):按照指定格式輸出日期字符串

結構化的時間(struct_time):struct_time元組共有9個元素共九個元素:(年,月,日,時,分,秒,一年中第幾周,一年中第幾天,夏令時)

import time#我們先以當前時間為準,讓大家快速認識三種形式的時間print(time.time()) # 時間戳:1487130156.419527
print(time.strftime("%Y-%m-%d %X")) #格式化的時間字符串:'2017-02-15 11:40:53'print(time.localtime()) #本地時區的struct_time
print(time.gmtime())    #UTC時區的struct_time
三種形式的時間實例
"""python中時間日期格式化符號:------------------------------------%y 兩位數的年份表示(00-99)%Y 四位數的年份表示(000-9999)%m 月份(01-12)%d 月內中的一天(0-31)%H 24小時制小時數(0-23)%I 12小時制小時數(01-12)%M 分鐘數(00=59)%S 秒(00-59)%a 本地簡化星期名稱%A 本地完整星期名稱%b 本地簡化的月份名稱%B 本地完整的月份名稱%c 本地相應的日期表示和時間表示%j 年內的一天(001-366)%p 本地A.M.或P.M.的等價符%U 一年中的星期數(00-53)星期天為星期的開始%w 星期(0-6),星期天為星期的開始%W 一年中的星期數(00-53)星期一為星期的開始%x 本地相應的日期表示%X 本地相應的時間表示%Z 當前時區的名稱  # 亂碼%% %號本身
"""
常用的時間日期格式化符號

由于計算機只能讀懂時間戳,所以在一些特定的場景下我們會把上面三種時間的表示方式進行轉換

# localtime([secs])
# 將一個時間戳轉換為當前時區的struct_time。secs參數未提供,則以當前時間為準。
 time.localtime()time.localtime(1539582935.9421027)gmtime([secs]) 和localtime()方法類似,gmtime()方法是將一個時間戳轉換為UTC時區(0時區)的struct_time。# mktime(t) : 將一個struct_time轉化為時間戳。print(time.mktime(time.localtime()))# strftime(format[, t]) : 把一個代表時間的元組或者struct_time(如由time.localtime()和# time.gmtime()返回)轉化為格式化的時間字符串。如果t未指定,將傳入time.localtime()。如果元組中任何一個# 元素越界,ValueError的錯誤將會被拋出。print(time.strftime("%Y-%m-%d %X", time.localtime()))#2018-10-15 13:57:56# time.strptime(string[, format])# 把一個格式化時間字符串轉化為struct_time。實際上它和strftime()是逆操作。print(time.strptime('2011-05-05 16:37:06', '%Y-%m-%d %X'))#time.struct_time(tm_year=2011, tm_mon=5, tm_mday=5, tm_hour=16, tm_min=37, tm_sec=6,#  tm_wday=3, tm_yday=125, tm_isdst=-1)#在這個函數中,format默認為:"%a %b %d %H:%M:%S %Y"。
利用結構化時間轉換
# asctime([t]) : 把一個表示時間的元組或者struct_time表示為這種形式:'Sun Jun 20 23:21:05 1993'。
# 如果沒有參數,將會將time.localtime()作為參數傳入。
print(time.asctime())#Sun Sep 11 00:43:43 2016# ctime([secs]) : 把一個時間戳(按秒計算的浮點數)轉化為time.asctime()的形式。如果參數未給或者為
# None的時候,將會默認time.time()為參數。它的作用相當于time.asctime(time.localtime(secs))。
print(time.ctime())  # Sun Sep 11 00:46:38 2016
print(time.ctime(time.time()))  # Sun Sep 11 00:46:38 2016
時間戳與格式化時間轉換為時間字符串
時間加減
import datetimeprint(datetime.datetime.now()) #返回 2016-08-19 12:47:03.941925
print(datetime.date.fromtimestamp(time.time()) )  # 時間戳直接轉成日期格式 2016-08-19
print(datetime.datetime.now() )
print(datetime.datetime.now() + datetime.timedelta(3)) #當前時間+3天
print(datetime.datetime.now() + datetime.timedelta(-3)) #當前時間-3天
print(datetime.datetime.now() + datetime.timedelta(hours=3)) #當前時間+3小時
print(datetime.datetime.now() + datetime.timedelta(minutes=30)) #當前時間+30分

時間替換
c_time  = datetime.datetime.now()
print(c_time.replace(minute=3,hour=2))
時間運算

random模塊

 import randomprint(random.random()) #(0,1)----float    大于0且小于1之間的小數print(random.randint(1,3))  #[1,3]      大于等于1且小于等于3之間的整數print(random.randrange(1,3)) #[1,3)    大于等于1且小于3之間的整數print(random.choice([1,'23',[4,5]]))      #1或者23或者[4,5]print(random.sample([1,'23',[4,5]],2))    #列表元素任意2個組合print(random.uniform(1,3))      #大于1小于3的小數,如1.927109612082716 
item=[1,3,5,7,9]
random.shuffle(item) #打亂item的順序,相當于"洗牌"
print(item)
random常見用法

os模塊

os模塊是與計算機操作系統交互的一個接口

os.getcwd() 獲取當前工作目錄,即當前python腳本工作的目錄路徑
os.chdir("dirname")  改變當前腳本工作目錄;相當于shell下cd
os.curdir  返回當前目錄: ('.')
os.pardir  獲取當前目錄的父目錄字符串名:('..')
os.makedirs('dirname1/dirname2')    可生成多層遞歸目錄
os.removedirs('dirname1')    若目錄為空,則刪除,并遞歸到上一級目錄,如若也為空,則刪除,依此類推
os.mkdir('dirname')    生成單級目錄;相當于shell中mkdir dirname
os.rmdir('dirname')    刪除單級空目錄,若目錄不為空則無法刪除,報錯;相當于shell中rmdir dirname
os.listdir('dirname')    列出指定目錄下的所有文件和子目錄,包括隱藏文件,并以列表方式打印
os.remove()  刪除一個文件
os.rename("oldname","newname")  重命名文件/目錄
os.stat('path/filename')  獲取文件/目錄信息
os.sep    輸出操作系統特定的路徑分隔符,win下為"\\",Linux下為"/"
os.linesep    輸出當前平臺使用的行終止符,win下為"\t\n",Linux下為"\n"
os.pathsep    輸出用于分割文件路徑的字符串 win下為;,Linux下為:
os.name    輸出字符串指示當前使用平臺。win->'nt'; Linux->'posix'
os.system("bash command")  運行shell命令,直接顯示
os.environ  獲取系統環境變量
os.path.abspath(path)  返回path規范化的絕對路徑
os.path.split(path)  將path分割成目錄和文件名二元組返回
os.path.dirname(path)  返回path的目錄。其實就是os.path.split(path)的第一個元素
os.path.basename(path)  返回path最后的文件名。如何path以/或\結尾,那么就會返回空值。即os.path.split(path)的第二個元素
os.path.exists(path)  如果path存在,返回True;如果path不存在,返回False
os.path.isabs(path)  如果path是絕對路徑,返回True
os.path.isfile(path)  如果path是一個存在的文件,返回True。否則返回False
os.path.isdir(path)  如果path是一個存在的目錄,則返回True。否則返回False
os.path.join(path1[, path2[, ...]])  將多個路徑組合后返回,第一個絕對路徑之前的參數將被忽略
os.path.getatime(path)  返回path所指向的文件或者目錄的最后存取時間
os.path.getmtime(path)  返回path所指向的文件或者目錄的最后修改時間
os.path.getsize(path) 返回path的大小
os操作大全
os.path.normpath()在Linux和Mac平臺上,該函數會原樣返回path,在windows平臺上會將路徑中所有字符轉換為小寫,并將所有斜杠轉換為飯斜杠。
>>> os.path.normcase('c:/windows\\system32\\')   
'c:\\windows\\system32\\'   規范化路徑,如..和/
>>> os.path.normpath('c://windows\\System32\\../Temp/')   
'c:\\windows\\Temp'   >>> a='/Users/jieli/test1/\\\a1/\\\\aa.py/../..'
>>> print(os.path.normpath(a))
/Users/jieli/test1
os.path.normcase()與os.path.normpath()
os路徑處理
#方式一:推薦使用
import os
#具體應用
import os,sys
possible_topdir = os.path.normpath(os.path.join(os.path.abspath(__file__),os.pardir, #上一級
    os.pardir,os.pardir
))
sys.path.insert(0,possible_topdir)#方式二:不推薦使用
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
路徑處理

sys模塊

sys.argv     #命令行參數List,第一個元素是程序本身路徑 
sys.modules.keys()   #返回所有已經導入的模塊列表 
sys.exc_info()    #獲取當前正在處理的異常類,exc_type、exc_value、exc_traceback當前處理的異常詳細信息 
sys.exit(n)    #程序,正常退出時exit(0) 
sys.hexversion    #獲取Python解釋程序的版本值,16進制格式如:0x020403F0 
sys.version    #獲取Python解釋程序的版本信息 
sys.maxint     #最大的Int值 
sys.maxunicode    #最大的Unicode值 
sys.modules    #返回系統導入的模塊字段,key是模塊名,value是模塊 
sys.path     #返回模塊的搜索路徑,初始化時使用PYTHONPATH環境變量的值 
sys.platform    #返回操作系統平臺名稱 
sys.stdout     #標準輸出  
sys.stdin     #標準輸入 
sys.stderr     #錯誤輸出  
sys.exc_clear()   #用來清除當前線程所出現的當前的或最近的錯誤信息 
sys.exec_prefix   #返回平臺獨立的python文件安裝的位置 
sys.byteorder    #本地字節規則的指示器,big-endian平臺的值是'big',little-endian平臺的值是'little' 
sys.copyright    #記錄python版權相關的東西 
sys.api_version   #解釋器的C的API版本 
sys.version_info   #獲取Python解釋器的版本信息 
sys.getwindowsversion  #獲取Windows的版本
sys.getdefaultencoding  #返回當前你所用的默認的字符編碼格式
sys.getfilesystemencoding #返回將Unicode文件名轉換成系統文件名的編碼的名字
sys.setdefaultencoding(name) #用來設置當前默認的字符編碼
sys.builtin_module_names #Python解釋器導入的模塊列表 
sys.executable    #Python解釋程序路徑 
sys.stdin.readline   #從標準輸入讀一行,sys.stdout.write("a") 屏幕輸出a
View Code

處理模塊:我們在使用模塊的某一個功能前,需要用import,__import__命令導入。那我們在執行import module_name的時候,python內部發生了什么呢?簡單的說,就是搜索module_name。根據sys.path的路徑來搜索module.name

import sys
print(sys.path)['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client']
View Code

我們以后寫好的模塊就可以放到上面的某一個目錄下,便可以正確搜索到了。當然也可以添加自己的模塊路徑。sys.path.append(“my module path”)。

>>> sys.path.append('my module path')
>>> sys.path
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PILcompat', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', 'my module path']
View Code

path列表是一個由目錄名構成的列表, Python 從中查找擴展模塊( Python 源模塊, 編譯模塊,或者二進制擴展).
啟動 Python 時,這個列表根據內建規則, PYTHONPATH 環境變量的內容, 以及注冊表( Windows 系統)等進行初始化.
由于它只是一個普通的列表, 你可以在程序中對它進行操作。使用sys模塊查找已導入的模塊(sys.modules):
modules 字典包含所有加載的模塊。 import 語句在從磁盤導入內容之前會先檢查這個字典。Python 在處理你的腳本之前就已經導入了很多模塊.

>>> import sys
>>> type(sys.modules)
<type 'dict'>
>>> sys.modules.keys()
['copy_reg', 'sre_compile', '_sre', 'encodings', 'site', '__builtin__', 'sysconfig', '__main__', 'encodings.encodings','abc', 'posixpath', '_weakrefset', 'errno', 'encodings.codecs', 'sre_constants', 're', '_abcoll', 'types', '_codecs', 'encodings.__builtin__', '_warnings', 'genericpath', 'stat', 'zipimport', '_sysconfigdata', 'warnings', 'UserDict', 'encodings.utf_8', 'sys', 'codecs', 'readline', '_sysconfigdata_nd', 'os.path', 'sitecustomize', 'signal', 'traceback','linecache', 'posix', 'encodings.aliases', 'exceptions', 'sre_parse', 'os', '_weakref']>>> len(sys.modules.keys())
43 
View Code

打印進度條

#指定寬度
print("[%-15s]"%'#')
print("[%-15s]"%'##')#打印%
print("%s%%"%(100))  #第二個%號代表取消第一個%的特殊意義#可傳參來控制寬度
print('[%%-%ds]' %50) #[%-50s]
print(('[%%-%ds]' %50) %'#')
print(('[%%-%ds]' %50) %'##')
print(('[%%-%ds]' %50) %'###')'''
字符串輸出 %s,%10s--右對齊,占位符10位;%-10-----左對齊,占位符10位;'''
import sys
import timedef progress(percent,width=50):if percent >= 1:percent=1show_str=('[%%-%ds]' %width) %(int(width*percent)*'#')print('\r%s %d%%' %(show_str,int(100*percent)),file=sys.stdout,flush=True,end='')#\r是回車的意思#應用
data_size=102500
recv_size=0
while recv_size < data_size:time.sleep(0.1) #模擬數據的傳輸延遲recv_size+=1024 #每次收1024
percent=recv_size/data_size #接收的比例progress(percent,width=70) #進度條的寬度70
View Code

print官方文檔分析

print(…) 
print(value, …, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False) 
Prints the values to a stream, or to sys.stdout by default. 
Optional keyword arguments: 
file: a file-like object (stream); defaults to the current sys.stdout. 
sep: string inserted between values, default a space. 
end: string appended after the last value, default a newline. 
flush: whether to forcibly flush the stream.參數解析 
value:需要輸出的值,可以是多個,用”,”分隔。 
sep:多個輸出值之間的間隔,默認為一個空格。 
end:輸出語句結束以后附加的字符串,默認是換行(’\n’)。 
file:輸出的目標對象,可以是文件也可以是數據流,默認是“sys.stdout”。 
flush:flush值為True或者False,默認為Flase,表示是否立刻將輸出語句輸出到目標對象。
print參數分析
默認:print(value, …, sep=’ ‘, end=’\n’, file=sys.stdout, flush=False)>>> print("hello world")
hello world12當value有多個:>>> print("hello","world")
hello world12當sep為”,”>>> print("hello","world",sep=",")
hello,world12當end為“”>>>print("hello","world",end="") 
>>>print("hello","world")
hello worldhello world123當file指向test.txttest = open("test.txt", "w")
print("hello","world",sep="\n", file=test)
123此時當前目錄下會新建一個test.txt文件里面內容為hello
world12flush=False 
該參數只有兩個選項True or False。 
當flush=False時,輸出值會存在緩存,然后在文件被關閉時寫入。 
當flush=True時,輸出值強制寫入文件。
實際舉例

functools

該模塊為高階函數提供支持——作用于或返回函數的函數被稱為高階函數。在該模塊看來,一切可調用的對象均可視為本模塊中所說的“函數”。

python3.6中的functools

import functools
for i in dir(functools):print(i)運行結果
'''
MappingProxyType
RLock
WRAPPER_ASSIGNMENTS
WRAPPER_UPDATES
WeakKeyDictionary
_CacheInfo
_HashedSeq
__all__
__builtins__
__cached__
__doc__
__file__
__loader__
__name__
__package__
__spec__
_c3_merge
_c3_mro
_compose_mro
_convert
_find_impl
_ge_from_gt
_ge_from_le
_ge_from_lt
_gt_from_ge
_gt_from_le
_gt_from_lt
_le_from_ge
_le_from_gt
_le_from_lt
_lru_cache_wrapper
_lt_from_ge
_lt_from_gt
_lt_from_le
_make_key
cmp_to_key
get_cache_token
lru_cache
namedtuple
partial
partialmethod
recursive_repr
reduce
singledispatch
total_ordering
update_wrapper
wraps
'''

partial函數(偏函數)

把一個函數的某些參數設置默認值,返回一個新的函數,調用這個新函數會更簡單

import functoolsdef show_parameter(*args, **kw):print(args)print(kw)p1 = functools.partial(show_parameter(), 1, 2, 3)p1()
'''
(1, 2, 3)
{}
'''
p1(4, 5, 6)
'''
(1, 2, 3, 4, 5, 6)
{}
'''
p1(a='python', b='itcast')
'''
(1, 2, 3)
{'a': 'python', 'b': 'itcast'}
'''p2 = functools.partial(show_parameter, a=3, b='linux')p2()
'''
()
{'a': 3, 'b': 'linux'}
'''
p2(1, 2)
'''
(1, 2)
{'a': 3, 'b': 'linux'}
'''
p2(a='python', b='itcast')
'''
()
{'a': 'python', 'b': 'itcast'}
'''

wraps函數

使用裝飾器時,有一些細節需要被注意。例如,被裝飾后的函數其實已經是另外一個函數了(函數名等函數屬性會發生改變)。

添加后由于函數名和函數的doc發生了改變,對測試結果有一些影響,例如

def outter(func):"outter function"def wrapper():"wrapper function"print('outter something')return func()return wrapper@outter
def test():"test function"print('I am test')test()print(test.__doc__)    #這里面的__doc__改變了執行結果
'''
outter something
I am test
wrapper function
'''

所以,Python的functools包中提供了一個叫wraps的裝飾器來消除這樣的副作用

import functoolsdef outter(func):"outter function"@functools.wraps(func)def wrapper():"wrapper function"print('outter something')return func()return wrapper@outter
def test():"test function"print('I am test')test()
print(test.__doc__)執行結果
'''
outter something
I am test
test function
'''

  

?

轉載于:https://www.cnblogs.com/596014054-yangdongsheng/p/9770662.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/279186.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/279186.shtml
英文地址,請注明出處:http://en.pswp.cn/news/279186.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

使用aSpotCat控制您的Android應用權限

Viewing the permissions of each installed Android app requires digging through the Manage Applications screen and examining each app one by one — or does it? aSpotCat takes an inventory of the apps on your system and the permissions they require. 要查看每…

xtrabackup備份mysql“ib_logfile0 is of different”錯誤分析

今天用xtrabackup工具完整備份mysql數據庫的時候出現“./ib_logfile0 is of different”錯誤&#xff0c;具體的日志信息如下: 我第一時間查詢了百度和谷歌都沒有找見相對應的答案。決定從錯誤日志入手&#xff0c;上面的日志提示說&#xff1a;mysql數據庫inondb的日志文件的大…

java socket 報文解析_java socket解析和發送二進制報文工具(附java和C++轉化問題)

解析:首先是讀取字節:/*** 讀取輸入流中指定字節的長度* * 輸入流**paramlength 指定長度*return指定長度的字節數組*/public static byte[] readBytesFromTo(byte[] buffer, int from, intlength) {byte[] sub new byte[length];int cur 0;for (int i from; i < length …

Ubuntu防火墻:ufw

原始linux的防火墻是iptables&#xff0c;以為過于繁瑣&#xff0c;各個發行版幾乎都有自己的方案; ubuntu下的防火墻是ufw[ubuntu fireward的縮寫]&#xff0c;centos的防火墻是fireward ubuntu下&#xff1a; 啟用或者關閉防火墻 sudo ufw enable|disable sudo ufw default d…

如何使自己的不和諧機器人

Discord has an excellent API for writing custom bots, and a very active bot community. Today we’ll take a look at how to get started making your own. Discord具有出色的用于編寫自定義機器人的API&#xff0c;以及非常活躍的機器人社區。 今天&#xff0c;我們將探…

?css3屬性選擇器總結

css3屬性選擇器總結 &#xff08;1&#xff09;E[attr]只使用屬性名&#xff0c;但沒有確定任何屬性值 <p miaov"a1">111111</p> <p miaov"a2">111111</p> p[miaov]{background: red;} /*所有屬性為miaov的元素都會被背景變紅&a…

java復合賦值運算符_Java 之復合賦值運算符

1.引入問題切入正題&#xff0c;看下面代碼&#xff0c;結果應該是怎么樣的public class App{public static void main( String[] args ){byte a1 ;int b 10;a ab;System.out.println(a);ab;System.out.println(a);}}這段代碼的執行結果是什么&#xff1f;&#xff1f;2. 執行…

程序代碼初學者_初學者:如何使用熱鍵在Windows中啟動任何程序

程序代碼初學者Assigning shortcut keys to launch programs in Windows is probably one of the oldest geek tricks in the book, but in true geek fashion we are going to show you how to do it in Windows 8. 分配快捷鍵以在Windows中啟動程序可能是本書中最古老的怪胎技…

stevedore——啟用方式

2019獨角獸企業重金招聘Python工程師標準>>> setuptools維護的入口點注冊表列出了可用的插件&#xff0c;但是并沒有為最終用戶提供使用或啟用的方法。 下面將描述用于管理要使用的擴展集的公共模式。 通過安裝方式啟用 對于許多應用程序&#xff0c;僅僅安裝一個擴…

java 重置定時器_可重置Java定時器

我想有一個java.utils.Timer與一個可重置時間在java.I需要設置一次off事件發生在X秒。如果在創建定時器的時間和X秒之間沒有發生任何事情&#xff0c;則事件會正常發生。然而&#xff0c;如果在X秒之前&#xff0c;我決定該事件應該發生在Y秒后&#xff0c;然后我想要能夠告訴定…

C# -- 文件的壓縮與解壓(GZipStream)

文件的壓縮與解壓 需引入 System.IO.Compression; 1.C#代碼&#xff08;入門案例&#xff09; 1 Console.WriteLine("壓縮文件...............");2 using (FileStream fr File.OpenRead("d:\\test.txt"))3 {4 …

win7屏保文件.scr_如何將屏保添加到Ubuntu 12.04

win7屏保文件.scrUbuntu 12.04 doesn’t ship with any screen savers, just a black screen that appears when your system is idle. If you’d rather have screensavers, you can swap gnome-screensaver for XScreenSaver. Ubuntu 12.04沒有附帶任何屏幕保護程序&#xff…

簡單讀寫XML文件

IPAddress.xml 文件如下&#xff1a; <?xml version"1.0" encoding"utf-8"?><IP><IPAddress>192.168.0.120</IPAddress></IP> 在 Form 窗體(讀取XML配置.Designer.cs)中有如下控件&#xff1a; 代碼 privateSystem.Wind…

如何與Ubuntu One同步配置文件

Ubuntu One lets you easily synchronize files and folders, but it isn’t clear how to sync configuration files. Using Ubuntu One’s folder synchronization options or some symbolic links, you can synchronize configuration files across all your computers. Ubu…

java 輸入流關閉順序_Java IO流中先關閉輸出流還是先關閉輸入流?為什么?

java中需要手動釋放的資源bai常見的有以下兩個&#xff1a;流相du關資zhi源流相關資源一般遵循&#xff1a;1)先開后關dao&#xff0c;先開的輸入流&#xff0c;再開的輸出流&#xff0c;通過讀取輸入流寫入輸出流中&#xff0c;那么應該先關輸出流&#xff0c;再關輸入流&…

解析Linux操作系統文件目錄

隨著Linux的不斷發展&#xff0c;越來越多的人開始使用Linux&#xff0c;對于那些剛剛接觸的人來說&#xff0c;恐怕最先感到困惑的就是那些“不明不白”的目錄了。如果想熟練使用Linux&#xff0c;讓Linux聽命于自己&#xff0c;就必須掌握這些目錄&#xff0c;下面就以Xteam公…

智能家居設備_您的智能家居設備正在監視您嗎?

智能家居設備In a world where we’re all paranoid about devices spying on us (and rightfully so), perhaps no other devices receive more scrutiny than smarthome products. But is that scrutiny warranted? 在一個我們都對監視設備的人都抱有偏執的世界(理應如此)&a…

Jenkins忘記admin密碼處理方法

1、先找到enkins/config.xml文件&#xff0c;并備份。 此文件位于Jenkins系統設置的主目錄&#xff0c;根據自己的配置情況而定。我的位置如下 /data/temp/jenkins/config.xml2、然后編輯config.xml刪除<useSecurity>true</useSecurity>至</securityRealm>&a…

java讀取excel某個單元格的值_java poi怎么獲取excel單元格的內容

展開全部package edu.sjtu.erplab.poi;import java.io.InputStream&chww.xqy.chain" target"_blank" class"link-baike">FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStream;impor…

科研繪圖工具軟件_如何在Windows 10 Mail中使用繪圖工具

科研繪圖工具軟件Microsoft recently released a new feature for the Windows 10 Mail app that lets you convey messages with drawings right inside the body of an email. This is a great way to quickly sketch things like graphs or tables to get your point across…