예제 #1
0
def main():
	rfname = raw_input('enter a file name: ')
	if not path.exists(rfname):
		print rfname, 'does not exist.'
		return
	prompt = '(O)verwrite or (C)reate(default)? : '
	choice = raw_input(prompt)

	if choice and choice[0].lower() == 'o':
		wfname = rfname
	else:
		curtime = '%02d'*5 % \
			(gm().tm_mon, gm().tm_mday, gm().tm_hour+8, gm().tm_min, gm().tm_sec)
			# time-zone is American
		wfname = rfname + '_' + curtime
		
	newlines = strip_lc(rfname)
	fobj = open(wfname, 'w')
	#fobj.write(newlines) #write()'s argument required to be string
	fobj.writelines(['%s%s'% (line,ls) for line in newlines]) #add '/n'for each line
	fobj.close()

	print 'done, file:', wfname
def promAGet(tiempo, promedios):
    from time import asctime as asc, gmtime as gm
    sender = '?t=' + asc(gm(t))
    return sender + '&' + '&'.join(
        ['var' + str(n) + '=' + str(a) for n, a in enumerate(promedios)])
def promALinea(tiempo, promedios):
    from time import asctime as asc, gmtime as gm
    return asc(gm(t)) + ',' + ','.join([str(a) for a in promedios])
예제 #4
0
#!C:/Python27/python.exe
print("Content-Type: text/html\n")
from json import loads as jl
from time import gmtime as gm
import datetime

print("<h3>list of all call Received today : </h3>")
k = "buffer/call-" + str(gm().tm_mday).zfill(2) + str(
    gm().tm_mon).zfill(2) + str(gm().tm_year) + ".json"
with open(k) as f:
    data = jl(f.read())
for i in data[len(data):0:-1]:
    print("//**********************" + "<br/>")
    print("Number : " + i['number'] + "<br/>")
    print("Time : " + str(datetime.datetime.fromtimestamp(i['times'])) +
          "<br/>")
예제 #5
0
# This the sleep function causes the script to wait x number of seconds defore moving onto the next task
time.sleep(2)
print('All Done!')

# 2) Import time using the alias tim to test the function
import time as tim
tim.sleep(5)
print("That was a long time!")

# 3) Import a single function from the time module
from time import gmtime
gmtime()

# 4) Import gmtime using an alias
from time import gmtime as gm
gm()

# 5) Ansewring the following questions using functions within the intertools module
import itertools as iter
# Get how many pairs of 'ABC' and '123' there be
ABC123 = list(iter.product(['A', 'B', 'C'], ['1', '2', '3']))
# Get how many pairs of abcd there can be
pairs_abcd = list(iter.combinations('abcd', 2))
# Get how many different combinations of 'abcd' there can be
two_combo_abcd = list(iter.permutations('abdc', 2))
# use len to answer how many results there are
print(len(ABC123))
print(len(pairs_abcd))
print(len(two_combo_abcd))

# 6) Import the json module and use it to read the data file profiles.json into a list of dictionaries
예제 #6
0
import time

value = time.strf('%c',time.gm())
print(value)
예제 #7
0
 def today_y_m_d(self):
     from time import gmtime as gm
     gm = gm()
     pre_z = lambda pre_z: str(pre_z).rjust(2, "0")
     return f"{gm.tm_year}-{pre_z(gm.tm_mon)}-{pre_z(gm.tm_mday)}"