python basic】的更多相关文章

1. How to run the python file? python ...py 2. UTF-8 is a character encoding, just like ASCII. 3. round(floating-point number) 4. %r print the way you write. It prints whatever you write, even if you have special characters, such as '\n'. 5. how to o…
From: http://learnpythonthehardway.org/book Comment with line comment: Ctrl + slash Run: Shift + F10 Next Break Point: F9 Run code partially in Console: Right Click +  Execute Selection in Console English Learning: + plus - minus / slash * asterisk %…
01.variable ''' 변수(variable) - 자료(data)를 임시(휘발성) 저장하는 역할 - 실제 자료가 아닌 자료의 주소를 저장한다.(참조변수) ''' # 1. 변수와 자료 print('변수와 자료') # 콘솔 출력 var1 = "hello python" # or 'hello python' print(var1) # 변수 내용 출력 print(type(var1)) # 자료형 확인 - <class 'str'> #…
#遍历一个序列,很多传统语言过来的,习惯用下标遍历,Python中序列是可迭代的,直接for即可! colors=['red','green','blue','yellow'] for color in colors: print color #遍历倒序,用range的负数来遍历,不如直接反转遍历for color in reversed((colors): print (color) #zip真的不错,尤其是处理2个序列非常简洁,遍历2个collectionnames=['loe','lili…
__author__ = 'student' l=[] l=list('yaoxiaohua') print l print l[0:2] l=list('abc') print l*3 l.append(4) print l l.extend('de') print l print l.count('a') l.sort() print l l.reverse() print l l[0:2]=[1,2,3] print l print list(map (ord,'spam')) l = […
a = np.random.random((2,4)) a Out[5]: array([[0.20974732, 0.73822026, 0.82760722, 0.050551 ], [0.77337155, 0.06521922, 0.55524187, 0.59209907]]) # 求矩阵所有数据的和,最小值,最大值 np.sum(a) Out[7]: 3.812057513268513 np.min(a) Out[8]: 0.05055099733013646 np.max(a) O…
1.在cmd中直接输入'python'提示:'python'不是内部或外部命令,也不是可运行的程序或批处理文件. 原因:没有为Python设置环境变量. 解法:控制面板->系统->高级系统设置->环境变量->Path->编辑->添加';'以及exe所在文件夹的路径,e.g. ';D:\Python27' 2.调用其他目录下的.py文件中的函数,as follow: import sys sys.path.append('D:\\Python\\basic\\hello.…
Object Oriented Programming python new concepts of the object oriented programming : class encapsulation inheritance polymorphism the three features of an object are : identity, state and behaviora class is an abstraction which regroup objects who ha…
本章讲话介绍如何使用字符串格式化其他的值,并简单了解一下利用字符串的分割.联接.搜索等方法能做些什么. 基本字符串操作 所有标准的序列操作(索引.分片.乘法.判断成员资格.求长度.取最大最小值)对字符串同样适用,但,字符串都是不可变的,因此字符串的分片赋值是不合法的. 字符串格式化:精简版 字符串格式化 使用 字符串格式化操作符,即百分号 % 来实现. 在%的左侧放置一个字符串(格式化字符串),而右侧放置希望格式化的值. >>> format = 'My %s %s is footbal…