# -*- coding: UTF-8 -*-
# a = int(input())
# if a > 100:
# print 100
# else:
# print 0
# print('''
# line1
# line2
# ''')
# print("growth rate: %d%% %s" % (7,"minping"))
# classmates = ["aaa","bbb","ccc"]
# print(len(classmates))
# classmates.append("ddd")
# classmates.insert(1,"aaa1")
# res = classmates.pop()
# res = classmates.pop(1)
# classmates[1] = "bbbb1"
# L = ["apple",123, True]
# classmates[1] = L
# # print(classmates)
# # print(classmates[1][1])
# classmatessss = ("AAA","BBB","CCC")
# classmates
# # print(classmatessss)#tuple不可變,不能被二次賦值,也沒(méi)有append笨鸡,insert,pop等操作
# t = ('a',('b','c'),['A','B'])
# # print(len(t))
# # t[2][0] = 'a'
# # t[2][1] = 'b'
# # print(t)
# classmates[1] = t
# print(classmates)
# # classmates[1][0] = 'A'
# # classmates[1][1][0] = 'B'
# classmates[1][2][1] = 'b'
# # print(classmates)
# res1 = 'a'
# res2 = 'b'
# te = (res1, res2)
# print(te)
# res2 = 'B'
# print(te)
# classmates = ['a','b','c']
# t = (1, 2, classmates, 4)
# print(t)
# t[2][0] = 'A'
# print(t)
# t[2] = t[2].append('d')
# print(t)
# classmates = ["aaa","bbb","ccc",'ddd']
# print(len(classmates))
# classmates.append("eee")
# print(classmates)
# classmates.insert(1,"aaa1") #指定位置insert藤树,后面的元素順勢(shì)后移
# print(classmates)
# res = classmates.pop()
# print(classmates)
# res = classmates.pop(1) #指定位置pop,后面的元素順勢(shì)前移
# print(classmates)
# classmates[1] = "bbbb1" #指定位置賦值
# L = ["apple",123, True] #slice里每個(gè)元素類型可以不一樣
# classmates[1] = L #slice里的元素也可以為slice
# print(classmates)
# birth = input('birth: ')
# birth = int(birth)
# if birth < 2000:
# print('00前')
# else:
# print('00后')
# name = ['a','b','c']
# for k in name:
# print(k)
# sums = 0
# num = 99
# while num > 0:
# if num%2 == 0:
# continue
# sums += num
# num -=1
# if num == 95:
# break
# # nums = list(range(101))
# # for num in nums:
# # sums += num
# print(sums)
# d = {'minping':99, 'shuxin':98}
# print(d)
# print(d["minping"])
# print(d.get("minping1"))
# d.pop("minping")
# print(d)
# s = set([1,1,1,2,3,2])
# print(s)
# s.add(4)
# s.add(-1)
# print(s)
# s.remove(3)
# print(s)
# s.remove(-2)
# print(s)
# s1 = set([1,2,3])
# s2 = set([2,3,4])
# # print(s1 & s2) #交集
# # print(s1 | s2) #并集
# # print(s1 - s2) #差集
# s1.add([1,2])
# print(s1)
# print(max(1,2,3))
# def my_abs(x):
# if not isinstance(x,(int,float)):
# raise TypeError('bad param type')
# if x >= 0:
# return x
# return -x
# def nop():
# pass
# ddd = my_abs
# print(ddd('A'))
# import math
# def move(x, y, step, angle=0):
# nx = x + step*math.cos(angle)
# ny = y - step*math.sin(angle)
# return nx, ny
# x, y = move(100, 100, 60, math.pi/6)
# print(x, y)
# val = move(100, 100, 60, math.pi/6)
# print(val)
# def power(x, n=2):
# if not isinstance(x, (int, float)):
# raise TypeError('input param type error, must be a int or float')
# res = 1
# while n > 0:
# res = res * x
# n -= 1
# return res
# print(power(3,2))
# print(power(5))
# def stuinfo(name, gender, age=6, city='Beijing'):
# print('name:', name)
# print('gender:', gender)
# print('age:', age)
# print('city:', city)
# stuinfo('minp', 'male', city='shanghai')
# def add_end(l=[]):
# l.append('end')
# return l
# print(add_end([1,2,3]))
# print(add_end(['x','y','z']))
# print(add_end())
# print(add_end())
# print(add_end())
# def calc(*numbers):
# sums = 0
# for num in numbers:
# sums += num
# return sums
# res1 = calc(1,2,3) #傳入多個(gè)參數(shù)
# res2 = calc(*[1,2,3]) #傳入一個(gè)list
# res3 = calc(*(1,2,3)) #傳入一個(gè)tuple
# print(res1)
# print(res2)
# print(res3)
# def person(name, age, **kw):
# print('name is :', name, 'age is :', age, 'other is :',kw)
# person('Michael', 30)
# person('Bob', 35, city='Beijing')
# person('Adam', 45, gender='M', job='Engineer')
# from collections import Iterable
# extra = {'city':'Beijing', 'job':'Engineer'}
# extra = '123'
# if (isinstance(extra, Iterable)):
# for v in extra:
# print(v)
# else:
# print("eeee")
# person('Jack', 24, **extra)
# val = [(1,1), (2,4), (3,9)]
# for x, y in val:
# print(x,"ddd", y)
# val = [x*x for x in range(2,11) if x %2 == 0]
# print(val)
# val = [m+n for m in 'abc' for n in '123']
# print(val)
# val = [m+n+p for m in 'abc' for n in '123' for p in 'IVM']
# print(val)
# import os
# val = [d for d in os.listdir('.')]
# print(val)
# d = {'city':'Beijing', 'job':'Employer'}
# val = [k+'='+v for k,v in d.items()]
# print(val)
# L = ['Hello', 'World', 'IBM', 'Apple']
# val = [v.lower() for v in L]
# print(val)
# g = (x*x for x in range(1,3))
# # print(next(g))
# # print(next(g))
# # print(next(g))
# # print(next(g))
# for v in g:
# print(v)
# def fib(max):
# a, b = 1, 1
# while b < max:
# yield b
# a, b = b, a+b
# return 'done'
# f = fib(6)
# while True:
# try:
# v = next(f)
# print(v)
# except StopIteration as e:
# print('Gengerator return value is: ',e.value)
# break
# def f(x):
# return x*x
# r = map(f, list(range(10)))
# print(list(r))
# # for v in r:
# # print(v)
# print(list(map(str, [1,2,3,4,5])))
# def add(x, y):
# return x+y
# r = reduce(add, [1,2,3,4,5])
# print(r)
# def fn(x, y):
# return 10*x +y
# def str2int(strstr):
# return reduce(fn,list(map(int, list(strstr))))
# print(str2int('123456789'))
# def is_odd(n):
# return n%2 == 0
# r = filter(is_odd,[1,2,3,4,5])
# print(next(r))
# def _odder():
# n = 3
# while True:
# yield n
# n += 2
# def primes():
# yield 2
# it = _odder()
# while True:
# v = next(it)
# yield v
# p = primes()
# print(p)
# print(next(p))
# print(next(p))
# r = sorted([1,5,-3,6,2], key=abs)
# print(r)
# l = ['bob', 'about', 'Zoo', 'Credit']
# r = sorted(l, key = str.lower, reverse = True)
# print(r)
# def lazy_sum(*args):
# def my_sum():
# sums = 0
# for v in args:
# sums += v
# return sums
# return my_sum
# r = lazy_sum(*[1,2,3,4,5])
# print(r)
# print(r())
# def count():
# fs = []
# for i in range(1,4):
# def f():
# return i*i
# fs.append(f)
# return fs
# f1,f2,f3 = count()
# print(f1())
# print(f2())
# print(f3())
# def count_new():
# fs = []
# def f(i):
# def g():
# return i*i
# return g
# for i in range(1,4):
# fs.append(f(i))
# return fs
# f1,f2,f3 = count_new()
# print(f1())
# print(f2())
# print(f3())
# f = lambda x: x*x
# print(f)
# ' a test module '
# __author__ = 'mp'
# import sys
# # def test():
# # arg = sys.argv
# # if len(arg) == 1:
# # print('hello world')
# # elif len(arg) == 3:
# # print('Hello, %s %s' % (arg[1], arg[2]))
# # else:
# # print('too many param')
# def _private1(name):
# return 'hello %s' % name
# def _private2(name):
# return 'hi %s' % name
# def greeting(name):
# if len(name) < 3:
# print _private1(name)
# else:
# print _private2(name)
# return
# if __name__=='__main__':
# greeting("shuxin")
# class Student(object):
# def __init__(self, name, score):
# self.__name = name
# self.__score = score
# def print_score(self):
# print('%s:%s' % (self.__name, self.__score))
# bart = Student("minping", 99)
# lisa = Student("shuxin", 100)
# bart.__name = 'ddd'
# print(bart.__name)
# print(bart.Student.__name)
# # lisa.print_score()
# class Animal(object):
# def run(self):
# print('Animal is running...')
# class Dog(Animal):
# def run(self):
# print('Dog is running...')
# class Cat(Animal):
# def run(self):
# print('Cat is running...')
# dog = Dog()
# dog.run()
# cat = Cat()
# cat.run()
# print(isinstance(dog, Dog))
# print(isinstance(dog, Animal))
# print(isinstance(dog, Cat))
# def run_t(animal):
# animal.run()
# run_t(Animal())
# run_t(Dog())
# run_t(Cat())
# print(dir(cat))
# import logging
# def foo(s):
# return 10/int(s)
# def main():
# try:
# foo(0)
# except Exception as e:
# logging.exception(e)
# main()
# print('END')
# with open('2.py', 'a') as f:
# res = f.write('shuxin')
# with open('2.py') as f:
# res = f.read()
# print(res)
# from io import BytesIO as StringIO
# f = StringIO()
# f.write('minping')
# print(f.read())
# while True:
# s = f.readline()
# if s == '':
# break
# print(s)
# from io import BytesIO
# f = BytesIO()
# f.write('中文'.encode('utf-8'))
# print(f.getvalue())
# import os
# print(os.environ)
# import json
# d = {'name':'minping', 'age':20}
# r = json.dumps(d)
# print(r)
# print(isinstance(r, dict))
# re = json.loads(r)
# print(re)
# print(isinstance(re, dict))
# import json
# class Student(object):
# def __init__(self, name, score):
# self.name = name
# self.score = score
# # def obj2json(obj1):
# # return {'name':obj1.name, 'score':obj1.score}
# s = Student('shuxin', 99)
# print(json.dumps(s, default = lambda obj: obj.__dict__))
from datetime import datetime
now = datetime.now()
# print(now)
# dt = datetime(2013, 12, 12, 14, 15, 00)
# print(dt.timestamp())
print(datetime.fromtimestamp(1386828900.0))
python基本語(yǔ)法練習(xí)記錄
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門罩旋,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)啊央,“玉大人眶诈,你說(shuō)我怎么就攤上這事×哟欤” “怎么了册养?”我有些...
- 文/不壞的土叔 我叫張陵东帅,是天一觀的道長(zhǎng)压固。 經(jīng)常有香客問(wèn)我,道長(zhǎng)靠闭,這世上最難降的妖魔是什么帐我? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮愧膀,結(jié)果婚禮上拦键,老公的妹妹穿的比我還像新娘。我一直安慰自己檩淋,他們只是感情好芬为,可當(dāng)我...
- 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著蟀悦,像睡著了一般媚朦。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上日戈,一...
- 那天询张,我揣著相機(jī)與錄音,去河邊找鬼浙炼。 笑死份氧,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的弯屈。 我是一名探鬼主播蜗帜,決...
- 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼资厉!你這毒婦竟也來(lái)了厅缺?” 一聲冷哼從身側(cè)響起,我...
- 序言:老撾萬(wàn)榮一對(duì)情侶失蹤酌住,失蹤者是張志新(化名)和其女友劉穎店归,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體酪我,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡消痛,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了都哭。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片秩伞。...
- 正文 年R本政府宣布脸爱,位于F島的核電站遇汞,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏簿废。R本人自食惡果不足惜空入,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望族檬。 院中可真熱鬧歪赢,春花似錦、人聲如沸单料。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)扫尖。三九已至白对,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間藏斩,已是汗流浹背躏结。 一陣腳步聲響...
- 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像兆览,于是被迫代替她去往敵國(guó)和親屈溉。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- 小學(xué)語(yǔ)文修改病句的方法 修改病句是小學(xué)語(yǔ)文考試中常見(jiàn)的題型烤咧,在修改病句之前偏陪,我們應(yīng)該清晰的了解有哪些病句現(xiàn)象,下面...
- 成長(zhǎng)記錄-連載(三十六) ——我的第一篇五千字長(zhǎng)文饥脑,說(shuō)了什么,你一定想不到 并不是不想每天寫(xiě)公眾號(hào)宝泵,而是之前思考怎...
- 關(guān)注Swift好久了好啰,現(xiàn)在準(zhǔn)備好好學(xué)習(xí)一下,使用Playground練習(xí)Swift語(yǔ)法再好不過(guò)了儿奶,但是新建一個(gè)Pl...
- 我喜歡在安靜的午后邊放著音樂(lè)邊整理房間。陽(yáng)光從窗戶外照射進(jìn)來(lái)贤重,音符在房間內(nèi)跳動(dòng)茬祷,溫柔的聲線,優(yōu)美的旋律并蝗,讓平時(shí)工作...