justdo-it  

文章分类 -  Python编程

  • python编程中的if __name__ == 'main': 的作用和原理
    摘要:转自:http://www.dengfeilong.com/post/60.html 这个链接好像打不开了。。。 python编程中的if __name__ == 'main': 的作用和原理 在大多数编排得好一点的脚本或者程序里面都有这段if __name__ == 'main': ,虽然一直知道 阅读全文
    posted @ 2019-10-18 17:10 justdo-it 阅读(159) 评论(0) 推荐(0)
  • 【转】python文件读写——with open语句
    摘要:来源:https://www.cnblogs.com/ymjyqsx/p/6554817.html 读写文件是最常见的IO操作。Python内置了读写文件的函数,用法和C是兼容的。 读写文件前,我们先必须了解一下,在磁盘上读写文件的功能都是由操作系统提供的,现代操作系统不允许普通的程序直接操作磁盘, 阅读全文
    posted @ 2018-02-28 11:03 justdo-it 阅读(405) 评论(0) 推荐(0)
  • python——requests
    摘要:快速上手 http://docs.python-requests.org/zh_CN/latest/user/quickstart.html#id5 阅读全文
    posted @ 2018-02-25 22:16 justdo-it 阅读(107) 评论(0) 推荐(0)
  • python编写三角形
    摘要:(1)打印正三角形 # -*-coding:utf-8 -*- for i in range(1,10): for j in range(1,i+1): print '*', print ' ' (2)打印倒三角形 # -*-coding:utf-8 -*- for i in range(1,10) 阅读全文
    posted @ 2018-01-16 16:46 justdo-it 阅读(3470) 评论(0) 推荐(0)
  • python编写99乘法表
    摘要:# -*-coding:utf-8 -*- for i in range(1,10): for j in range(1,i+1): print '%d*%d=%2d'%(i,j,i*j), print '' 阅读全文
    posted @ 2018-01-16 16:35 justdo-it 阅读(709) 评论(0) 推荐(0)
  • Python字符串操作之字符串分割与组合
    摘要:转自 http://blog.csdn.net/seetheworld518/article/details/47346527 12、字符串的分割和组合 12.1 str.split():字符串分割函数 通过指定分隔符对字符串进行切片,并返回分割后的字符串列表。 语法: str.split(s, n 阅读全文
    posted @ 2018-01-16 16:26 justdo-it 阅读(70465) 评论(0) 推荐(4)
  • 【转】线程和进程的区别是什么?
    摘要:https://www.zhihu.com/question/25532384 作者:zhonyong链接:https://www.zhihu.com/question/25532384/answer/81152571来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 首 阅读全文
    posted @ 2018-01-03 10:15 justdo-it 阅读(119) 评论(0) 推荐(0)
  • 深刻理解Python中的元类(metaclass)
    摘要:类也是对象 在理解元类之前,你需要先掌握Python中的类。Python中类的概念借鉴于Smalltalk,这显得有些奇特。在大多数编程语言中,类就是一组用来描述如何生成一个对象的代码段。在Python中这一点仍然成立: 1 2 3 4 5 6 >>> class ObjectCreator(obj 阅读全文
    posted @ 2016-03-08 14:21 justdo-it 阅读(104) 评论(0) 推荐(0)
  • 饮水思源——python中常用基础类源码解析
    摘要:1.bool类 2.int类 3.long类 4.float类 5.str类 6.list类 7.tuple类 8.dict类 9.collections类 Counter类:为hashable对象计数,是字典的子类。引入自2.7。 defaultdict:使用工厂函数创建字典,使不用考虑缺失的字典 阅读全文
    posted @ 2016-03-08 14:16 justdo-it 阅读(231) 评论(0) 推荐(0)
  • Python字典高级使用方法汇总
    摘要:Python字典高级使用方法汇总字典(dictionary)是python中的一种非常灵活和强大的数据结构,可以完成很多操作。本文总结了一些除了基本的初始化、赋值、取值之外的常用的字典使用方法。使用dict创建字典的n种方法除了我们比较常用的d = {'a':1, 'b':2}来初始化字典外,还可以... 阅读全文
    posted @ 2016-01-11 18:53 justdo-it 阅读(668) 评论(0) 推荐(0)
  • Python 字典(Dictionary)操作详解
    摘要:Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串、数字、元组等其他容器模型。一、创建字典字典由键和对应值成对组成。字典也被称作关联数组或哈希表。基本语法如下:复制代码代码如下:dict = {'Alice': '2341', 'Beth': '9102', 'Cecil': '3... 阅读全文
    posted @ 2016-01-11 18:52 justdo-it 阅读(149) 评论(0) 推荐(0)
  • python—字典dictionary字典操作
    摘要:假设字典为dics = {0:'a', 1:'b', 'c':3}1.从字典中取值,当键不存在时不想处理异常[方法] dics.get('key', 'not found')[例如][解释] 当键'key'不存在是,打印'not found'(即想要处理的信息),当存在是输出键值。【其他解决方案一】... 阅读全文
    posted @ 2016-01-11 18:51 justdo-it 阅读(218) 评论(0) 推荐(0)
  • Python中何时使用断言
    摘要:这个问题是如何在一些场景下使用断言表达式,通常会有人误用它,所以我决定写一篇文章来说明何时使用断言,什么时候不用。为那些还不清楚它的人,Python的assert是用来检查一个条件,如果它为真,就不做任何事。如果它为假,则会抛出AssertError并且包含错误信息。例如:123456py> x =... 阅读全文
    posted @ 2016-01-06 14:27 justdo-it 阅读(465) 评论(0) 推荐(0)
  • python中字符串的分割和组合
    摘要:http://blog.sina.com.cn/s/blog_81e6c30b01019wro.html字符串的分割和组合>>> s'hello World! Everyone! This Is My First String!'>>> s.split()['hello', 'World!', ... 阅读全文
    posted @ 2016-01-06 10:38 justdo-it 阅读(211) 评论(0) 推荐(0)
  • python中字符串连接方式
    摘要:转载:http://www.jb51.net/article/55301.htm最原始的字符串连接方式:str1 + str2python 新字符串连接语法:str1, str2奇怪的字符串方式:str1 str2% 连接字符串:‘name:%s; sex: ' % ('tom', 'male')字... 阅读全文
    posted @ 2016-01-06 10:36 justdo-it 阅读(128) 评论(0) 推荐(0)
  • pycharm快捷键、常用设置、配置管理
    摘要:http://blog.csdn.net/pipisorry/article/details/39909057pycharm Learning tips学习技巧/pythoncharm/help/tip of the day:A special variant of the Code Complet... 阅读全文
    posted @ 2015-12-26 15:01 justdo-it 阅读(409) 评论(0) 推荐(0)
  • Python OS模块学习(一)
    摘要:http://www.cnblogs.com/wayneye/archive/2010/05/03/1726865.htmlos 模块提供了一个统一的操作系统接口函数, 这些接口函数通常是平台指定的,os 模块能在不同操作系统平台如 nt 或 posix中的特定函数间自动切换,从而能实现跨平台操作 ... 阅读全文
    posted @ 2015-12-20 21:38 justdo-it 阅读(217) 评论(0) 推荐(0)