随笔分类 -  Python

摘要:1.逻辑 实例来源于<<Redis实战>>这本书。 构建一个投票网站,为这个网站设置一些数值和限制条件:如果一篇文章获得至少200张支持票,那么网站就认为这篇文章是用户喜欢的文章;假如这个网站发布1000篇文章,而其中50篇符合网站对有趣文章的要求,那么网站要把这50篇网站放到首页推荐前100位至少 阅读全文
posted @ 2020-08-07 23:29 coder_xds 阅读(764) 评论(0) 推荐(0) 编辑
摘要:1.安装python3.6 yum -y install python3.6 2.查看python安装目录下面bin目录中是否已经含有pip whereis python python: /usr/bin/python /usr/bin/python2.7 /usr/bin/python3.6m / 阅读全文
posted @ 2020-08-05 23:42 coder_xds 阅读(383) 评论(0) 推荐(0) 编辑
摘要:1.函数返回值 >>> def say(): print('itxds') >>> print(say()) itxds None >>> 函数没有显性返回时,默认返回None 2.变量作用域-局部变量 >>> def cal(amount, rate): finalAmount = amount 阅读全文
posted @ 2020-08-02 00:02 coder_xds 阅读(370) 评论(0) 推荐(0) 编辑
摘要:1.函数文档 >>> def say(name, words): '函数定义阶段, name, words叫形参' '传递进来 name words是实参' print(name + ' say: ' + words) >>> say('itxds', 'hello') itxds say: hel 阅读全文
posted @ 2020-08-01 22:57 coder_xds 阅读(717) 评论(0) 推荐(0) 编辑
摘要:1.函数的创建和调用 >>> def MyFirstFunction(): print('hello') >>> MyFirstFunction() hello >>> >>> def test(name): print(name) >>> test('itxds') itxds >>> def a 阅读全文
posted @ 2020-08-01 21:39 coder_xds 阅读(1218) 评论(1) 推荐(1) 编辑
摘要:1.列表、元组和字符串的共同点 都可以通过索引得到每一个元素 默认索引值总是从0开始 可以通过分片的方法得到一个范围内的元素的集合 有很多共同的操作符(重复操作符、拼接操作符、成员关系操作符) 2.创建序列 >>> list('abcdefg') ['a', 'b', 'c', 'd', 'e', 阅读全文
posted @ 2020-08-01 16:52 coder_xds 阅读(204) 评论(0) 推荐(0) 编辑
摘要:1.format-位置格式化 >>> '{0},{1},{2}'.format(1,2,3) '1,2,3' 当参数个数小于(Max(位置索引)+1)时,系统报错 >>> '{0},{1},{3}'.format(1,2,3) Traceback (most recent call last): F 阅读全文
posted @ 2020-08-01 16:11 coder_xds 阅读(246) 评论(0) 推荐(0) 编辑
摘要:1.不使用系统内置方法操作字符串 >>> str = '程序员' >>> str1 = str[:1] +'(加)' + str[1:2] + '(班)' + str[2:] >>> str1 '程(加)序(班)员' 2.内置函数 capitalize() 转换首字母为大写 >>> str = 'p 阅读全文
posted @ 2020-08-01 14:25 coder_xds 阅读(152) 评论(0) 推荐(0) 编辑
摘要:1.创建和访问元组 >>> temp = (1,2,3,4,5,6) >>> temp[1] 2 >>> temp[5:] (6,) >>> temp[2:] (3, 4, 5, 6) >>> temp2 = temp[1:] >>> temp2 (2, 3, 4, 5, 6) 元组的访问同列表一样 阅读全文
posted @ 2020-08-01 12:59 coder_xds 阅读(118) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示