About the Tutorial



Download 2,85 Mb.
Pdf ko'rish
bet211/234
Sana28.05.2022
Hajmi2,85 Mb.
#614232
1   ...   207   208   209   210   211   212   213   214   ...   234
Bog'liq
python3 tutorial 060821094426

os.utime() Method 
Description 
The method utime() sets the access and modified times of the file specified by path. 
Syntax 
Following is the syntax for utime() method- 
os.utime(path, times) 
Parameters 

path
- This is the path of the file. 

times
- This is the file access and modified time. If times is none, then the file 
access and modified times are set to the current time. The parameter times consists 
of row in the form of (atime, mtime) i.e (accesstime, modifiedtime). 
Return Value 
This method does not return any value. 
Example 
The following example shows the usage of utime() method. 
# !/usr/bin/python3 
import os, sys, time 
os.chdir("d:\\tmp") 
# Showing stat information of file 
stinfo = os.stat('foo.txt') 
print (stinfo) 
# Using os.stat to recieve atime and mtime of file 
print ("access time of foo.txt: %s" %stinfo.st_atime) 
print ("modified time of foo.txt: %s" %stinfo.st_mtime) 
print (time.asctime( time.localtime(stinfo.st_atime))) 
# Modifying atime and mtime 
os.utime("foo.txt",(1330712280, 1330712292)) 
print ("after modification") 
print (time.asctime( time.localtime(stinfo.st_atime))) 
print ("done!!") 
When we run the above program, it produces the following result- 


Python 3 
319 
os.stat_result(st_mode=33206, 
st_ino=1688849860351098, 
st_dev=1017554828, 
st_nlink=1, 
st_uid=0, 
st_gid=0, 
st_size=0, 
st_atime=1455684273, 
st_mtime=1455684273, st_ctime=1455683589) 
access time of foo.txt: 1455684273.84375 
modified time of foo.txt: 1455684273.84375 
Wed Feb 17 10:14:33 2016 
after modification 
Fri Mar 2 23:48:00 2012 
done!! 

Download 2,85 Mb.

Do'stlaringiz bilan baham:
1   ...   207   208   209   210   211   212   213   214   ...   234




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish