
Python
文章平均质量分 91
yangcs2009
这个作者很懒,什么都没留下…
展开
-
Python中的urllib2库的使用
今天研究了下urllib2这个库的使用,才发现以前有很多不明白的东西,现在写下来也做个记录1. 最基础的应用 import urllib2 url = r'http://www.baidu.com'html = urllib2.urlopen(url).read() print html客户端与服务器端通过request与response来沟通,客户端先向服务端发送reque转载 2014-12-16 11:07:28 · 742 阅读 · 0 评论 -
celery基础
转自 http://sanwen.name/hexo/public/2016/10/02/celery%E7%AC%94%E8%AE%B0/1.何为消息队列?在不同系统(或物理设备)之间,应用软件之间,程序进程之间,常常会有各种互相的信息传递;为保证消息传递的可靠性,对所传消息引入一个保存的容器:一方面用来接收发送者产生的信息,一方面在接收者正常的情况下完成消息的派送,并在无法接收消息时对信息进行...转载 2018-03-26 20:51:44 · 1936 阅读 · 0 评论 -
Python基础总结
1.如果字符串里面有很多字符都需要转义,就需要加很多\,为了简化,Python还允许用r''表示''内部的字符串默认不转义,可以自己试试:>>> print '\\\t\\'\ \>>> print r'\\\t\\'\\\t\\原创 2015-10-09 11:00:58 · 537 阅读 · 0 评论 -
Pdb Commands
Startup and Helppython-mpdb.py[args]help[command]within a python file:importpdb...pdb.set_trace()begin the debuggerview a list of commands, or view help for a specificcommandbegin转载 2015-07-21 16:36:50 · 758 阅读 · 0 评论 -
rabbitmq demo学习
安装好后,rabbitmq服务就已经启动好了。接下来看下python编写Hello World!的实例。实例的内容就是从send.py发送“Hello World!”到rabbitmq,receive.py从rabbitmq接收send.py发送的信息。rabbitmq消息发送流程(来源rabbitmq官网)其中P表示produce,生产者的意思,也可以称为发送者,实例中表现为se转载 2015-05-22 15:33:28 · 1130 阅读 · 0 评论 -
The Python Tutorial 3——An Informal Introduction to Python
1、Comments in Python start with the hash character,#, and extend to the end of the physical line. A comment may appear at thestart of a line or following whitespace or code, but not within a stringl原创 2014-11-26 19:08:28 · 710 阅读 · 0 评论 -
The Python Tutorial 6——Modules
A module is a file containing Python definitions and statements. The file name is the module name with the suffix.py appended. Within a module, the module’s name (as a string) is available as the va原创 2014-12-02 15:37:18 · 672 阅读 · 0 评论 -
The Python Tutorial 4——More Control Flow Tools
4. More Control Flow Tools4.1. if Statements>>> x = int(raw_input("Please enter an integer: "))Please enter an integer: 42>>> if x < 0:... x = 0... print 'Negative changed to zero'原创 2014-11-27 15:18:02 · 831 阅读 · 0 评论 -
The Python Tutorial 2——Using the Python Interpreter
1、Typing an end-of-file character (Control-D on Unix,Control-Z onWindows)at the primary prompt causes the interpreter to exit with a zero exitstatus. If that doesn’t work, you can exit the interpr原创 2014-11-26 13:22:19 · 649 阅读 · 0 评论 -
The Python Tutorial 9——Classes
Python类概况:多继承、override、多态9.1. A Word About Names and Objects9.2. Python Scopes and Namespaces三种namespace,不同namespace间同名member互不影响A namespace is a mapping from names to objects. Most namesp原创 2014-12-10 15:24:40 · 652 阅读 · 0 评论 -
The Python Tutorial 8——Errors and Exceptions
两类错误:语法或者是逻辑 syntax errors and exceptions.8.1. Syntax Errors>>> while True print 'Hello world' File "", line 1, in ? while True print 'Hello world' ^SyntaxError: inv原创 2014-12-05 16:43:47 · 685 阅读 · 0 评论 -
The Python Tutorial 7——Input and Output
7.1. Fancier Output Formatting两种方法,自己设置或者使用str.format()还有对齐函数 str.rjust() method of string objects, which right-justifies a string in a field of a given width by paddingit with spaces on the lef原创 2014-12-04 20:18:58 · 617 阅读 · 0 评论 -
The Python Tutorial 5——Data Structures
5.1. More on ListsThe list data type has some more methods.>>> a = [66.25, 333, 333, 1, 1234.5]>>> print a.count(333), a.count(66.25), a.count('x') #Return the number of times x appears in the l原创 2014-11-28 16:31:50 · 792 阅读 · 0 评论 -
django model object序列化
提到序列化与反序列化,通常会想到 json ,xml .在J2EE的开发中,这是很常用的技术,比如一个java class与xml之间的序列化与反序列化,我们可以通过 xstream来实现,如果是与json之间的转换,我们可以通过 gson.jar或者jsonlib.jar 来实现。方法很多,也是常见的方法。但在python 中,我们常用的是json 的序列化,python2.7 已经包含了jso...转载 2018-04-23 18:26:34 · 4107 阅读 · 0 评论