2017年10月19日

python基本语法2.5--字符串的相关操作

摘要: # -*- coding: utf-8 -*- import string # strip去除空格 s = ' abcd efg ' print(s.strip()) print(s.lstrip()) print(s.rstrip()) print(s) # 字符串连接 print('abc_' 阅读全文

posted @ 2017-10-19 16:27 小嘤嘤 阅读(269) 评论(0) 推荐(0) 编辑

python基本语法2.4---汉诺塔的递归

摘要: 算法:当只有一个盘子的时候,只需要从将A塔上的一个盘子移到C塔上。 当A塔上有两个盘子是,先将A塔上的1号盘子(编号从上到下)移动到B塔上,再将A塔上的2号盘子移动的C塔上,最后将B塔上的小盘子移动到C塔上。 当A塔上有3个盘子时,先将A塔上编号1至2的盘子(共2个)移动到B塔上(需借助C塔),然后 阅读全文

posted @ 2017-10-19 15:16 小嘤嘤 阅读(251) 评论(0) 推荐(0) 编辑

python基本语法2.3--函数及参数传递

摘要: # -*- coding: utf-8 -*- # 函数定义和默认参数 def func(x, y = 500): print(x, y) func(150) func(100, 200) func(y = 300, x = 100) # 可变参数 def func(name, *numbers): print(name) print(numbers) func(... 阅读全文

posted @ 2017-10-19 14:57 小嘤嘤 阅读(301) 评论(0) 推荐(0) 编辑

python基本语法2.2--函数名当作变量传递

摘要: def do_sum(data,method): return method(data) print(do_sum([1,2,3,4],sum)) 阅读全文

posted @ 2017-10-19 14:56 小嘤嘤 阅读(424) 评论(0) 推荐(0) 编辑

python基本语法2.1--if判断和while,for循环

摘要: # -*- coding: utf-8 -*- # if判断 a = 100 b = 200 c = 300 if c == a: print(a) elif c == b: print(b) else: print(c) # None的判断 x = None if x is None: print('x is None') if not x: pri... 阅读全文

posted @ 2017-10-19 14:55 小嘤嘤 阅读(264) 评论(0) 推荐(0) 编辑

AlexNet源码

摘要: http://www.cnblogs.com/vipyoumay/p/7686230.html 阅读全文

posted @ 2017-10-19 14:54 小嘤嘤 阅读(1550) 评论(0) 推荐(0) 编辑

2017年10月18日

python基本语法1.4--初识爬虫

摘要: import requests import time import xml.etree.ElementTree as ET from multiprocessing.dummy import Pool as ThreadPoo; from xml.parsers.expat import ParserCreate class DefaultSaxHandler(object): d... 阅读全文

posted @ 2017-10-18 23:30 小嘤嘤 阅读(344) 评论(0) 推荐(0) 编辑

python基本语法1.5--调用numpy库的性能影响

摘要: import timeit sum_by_for = """ for d in data: s += d """ sum_by_sum = """ sum(data) """ sum_by_numpy_sum = """ import numpy numpy.sum(data) """ def timeit_using_list(n, loops): list_setup... 阅读全文

posted @ 2017-10-18 23:30 小嘤嘤 阅读(306) 评论(0) 推荐(0) 编辑

python基本语法1.3--注释说明以及空格说明

摘要: # -*- coding: utf-8 -*-#或者写成下面这种形式 # coding: utf-8 #注意空格的对齐try: x = 100 y = 200 except IndentationError: print('IndentationError: unexpected indent') # 单行注释 ''' 多行注释 多行注释 ''' # 多行代码 st... 阅读全文

posted @ 2017-10-18 23:27 小嘤嘤 阅读(858) 评论(0) 推荐(0) 编辑

python基本语法1.2--数的移位及与或抑或相关计算

摘要: #便于中文的显示# -*- coding: utf-8 -*- #指数表示 # a ** b power(a, b) print(10 ** 2) #100 print(10 ** 2.5) #316.22776601683796 #做除法 # //: 返回商的整数部分 print(23 // 5) #4 print(28.7 // 4.4) #6.0 #>向右移位做除法 print(16... 阅读全文

posted @ 2017-10-18 23:25 小嘤嘤 阅读(446) 评论(0) 推荐(0) 编辑

导航