Python
文章平均质量分 65
Albert_YuHan
bytedancer
展开
-
Python—判断变量的基本类型
Python—判断变量的基本类型type()>>> type(123)==type(456)True>>> type(123)==intTrue>>> type('abc')==type('123')True>>> type('abc')==strTrue>>> type('abc')==type(123)Falseisinstance()>>> isin原创 2017-10-18 10:46:07 · 301 阅读 · 0 评论 -
Python—numpy做矩阵运算
Python知识(6)--numpy做矩阵运算矩阵运算论numpy中matrix 和 array的区别:http://blog.csdn.net/vincentlipan/article/details/20717163matrix 和 array的差别: Numpy matrices必须是2维的,但是 numpy arrays (ndarrays)原创 2017-10-18 10:48:51 · 4707 阅读 · 0 评论 -
Pyhon—生成随机数
Python中的random模块Python中的random模块用于生成随机数。下面介绍一下random模块中最常用的几个函数。random.randomrandom.random()用于生成一个0到1的随机符点数: 0 random.uniform random.uniform的函数原型为:random.uniform(a, b),用于生成一个指定范围内原创 2017-10-18 10:57:13 · 281 阅读 · 0 评论 -
python 自然语言处理第三章
1.访问文件:A.本地文件import osfile=open(path)----指针file.read()----得到字符串for line in file ----遍历文件的每一行B.网络文件from urllib import urlopenfile=urlopen(url)file.read()2.分词:tokens=nl原创 2017-11-16 10:19:41 · 745 阅读 · 0 评论 -
Python函数传参是传参对象的值,还是参数对象的引用?
为了弄清楚python函数传参到底是传值还是传引用的问题,进行了下面的小实验(以列表对象为例):(1)如何让两个变量指向同一个对象?:a = [1,2,3,4]b = a[:]c = aprint('id(a)={}'.format(id(a)))print('id(b)={}'.format(id(b)))print('id(c)={}'.format(id(c)))#r...原创 2018-12-30 13:44:00 · 4001 阅读 · 2 评论 -
python - 位与,位或,位异或,左移,右移,取反,二进制,八进制,十进制
1、各种运算及其相应的操作符运算操作符说明按位与&按位或|按位异或^取反~左移<<左移一位相当于除以2右移>>python的位与,位或,位异或,左移,右移,取反&位与,|位或,^位异或,左移,x>>n ==> x*2**n<<右...原创 2019-08-09 16:50:30 · 514 阅读 · 0 评论