
Python
文章平均质量分 50
Goith
这个作者很懒,什么都没留下…
展开
-
Python 基础-数值
>>> a = 3.0 + 4.0j>>> float(a)Traceback (most recent call last): File "", line 1, in TypeError: can't convert complex to float>>> a.real3.0>>> a.imag4.0>>> abs(a) # sqrt(a.real**2 + a.imag**2)5.0>>>原创 2017-05-27 22:11:23 · 290 阅读 · 0 评论 -
No module named mysqldb--Django
Use one of this commands, depends what os and software do u have and useeasy_install mysql-python (mix os)pip install mysql-python原创 2017-05-27 22:15:31 · 200 阅读 · 0 评论 -
python中xrange和range的异同
range 函数说明:range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列。range示例: >>> range(5) [0, 1, 2, 3, 4] >>> range(1,5) [1, 2, 3, 4] >>> range(0,6,2)[0, 2, 4]xrange 函数说明:用法与range完全相同,所不原创 2017-05-27 22:14:48 · 212 阅读 · 0 评论 -
Python 学习笔记20130928
__doc__:函数属性,文档字符串;PYTHON中元组与列表的区别列表中的项目应该包括在方括号中,你可以添加、删除或是搜索列表中的项目。由于你可以增加或删除项目,所以列表是可变的数据类型,即这种类型是可以被改变的。 元组和列表十分类似,但是元组是不可变的.也就是说你不能修改元组。元组通过圆括号中用逗号分割的项目定义。元组通常用在使语句或用户定义的函数能够安全地采用一组值的时候,即被使用的元组的值原创 2017-05-27 22:14:45 · 181 阅读 · 0 评论 -
raw_input() 与 input() __ Python 【转】
原文地址:http://www.cnblogs.com/way_testlife/archive/2011/03/29/1999283.html这两个均是 python 的内建函数,通过读取控制台的输入与用户实现交互。但他们的功能不尽相同。举两个小例子。>>> raw_input_A = raw_input("raw_input: ")raw_input: abc >>> input_A = in原创 2017-05-27 22:14:42 · 194 阅读 · 0 评论 -
CentOS6.4上安装Django1.6 【转】
原文地址:http://www.xshell.net/python/Centos64_Python66_Django16.htmlCentOS6.4系统最小化安装以后,默认带着Python2.6.6,直接可以安装Django1.6 下载Django1.6:wget -c https://www.djangoproject.com/m/releases/1.6/Django-1.6b1.tar.g原创 2017-05-27 22:14:16 · 559 阅读 · 0 评论 -
The Zen of Python, by Tim Peters
Beautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is better than complicated.Flat is better than nested.Sparse is better than dense.Readability count原创 2017-05-27 22:11:58 · 433 阅读 · 0 评论 -
python 基础-模块
>>> import fibo # 导入一个fibo.py文件,里面可以定义函数,这样 Python可以直接调用fibo.py中的函数。其他导入方法>>> from fibo import fib, fib2>>> from fibo import *6.1.1 模块搜索路径: 导入一个叫spam的模块时,解释器先在当前目录中搜索名为spam.py的文件,然后在环境变量PYTHONPATH指琮原创 2017-05-27 22:11:54 · 287 阅读 · 0 评论 -
Python 基础-函数
>>> def fib2(n): #return Fibonacci series up to n #如何从函数中返回一个包含菲波那契数列的数值链表... """ Return a list containing the Fibonacci series up to n. """... result = []... a,b=0,1... while原创 2017-05-27 22:11:35 · 312 阅读 · 0 评论 -
Python - 编程 (流程控制) 区别C 和我知道语言的用法
>>> # Fibonacci series:... # the sum of two elements defines the next... a,b = 0,1 #相当于:a=0;b=1;>>> while b... print b... a,b=b,a+b... 112358>>>循环体是缩进的:缩进是Python对语句分组的方法。 Python仍没有提供一个智能编原创 2017-05-27 22:11:32 · 462 阅读 · 0 评论 -
Python 基础 - Unicode \\ 链表
>>> u'hello world'u'hello world'>>> #引号前小写的“u”表示这里创建的是一个Unicode字符串。如果你想加入一个特殊字符,可以使用Python的 Unicode-Escape 编码:>>> u'hello\u0020World!'u'hello World!'>>> 链表>>> a = ['spam','eggs',100,1234]>>> a['spam',原创 2017-05-27 22:11:29 · 220 阅读 · 0 评论 -
Python 基础 - 字符串
>>> ' spam eggs'' spam eggs'>>> ' doesn\' t'" doesn' t">>> ' doesn\'t'" doesn't">>> u'hello world!'u'hello world!'>>> " doesn't "" doesn't ">>> ' "Yes," he said.'' "Yes," he said.'>>> "\"Yes,\" he sai原创 2017-05-27 22:11:26 · 207 阅读 · 0 评论 -
Python格式化中使用%与C prinf格式输出的区别
一.格式1.1 C printf()的一般格式 printf(格式控制,输出列表); 例:int i = 3; double f = 4.56; printf("%d,%f", i,f);1.2 PYTHON 格式化输出 格式标记字符串 % 要输出的值组 其中,左边部分的”格式标记字符串“可以完全和c中的一致。右边的'值组'如果有两个及以原创 2017-05-27 22:18:33 · 2778 阅读 · 0 评论