http://dlwt.csdn.net/fd.php?i=858467711513251&s=27caceefbe77d6532f648bb5ae3bc048 這個是Python for MyEclipse的插件php
http://dlsw.baidu.com/sw-search-sp/soft/6e/17016/python-3.3.5.1418106245.msi 這個是Python for Windows 安裝文件java
安裝好所須要的文件 。便可在MyEclipse裏面開始Python最簡單的測試了。python
首先選擇Python的編譯器 在MyEclipse Windows-preferences New
app
輸入名稱less
選擇編譯器
dom
選擇全部的 確認OK 等待一下安裝
ide
完畢以後 就能夠開始建立Python工程測試了測試
選擇projectspa
選擇Pydev Project 下一步
.net
選擇個語法版本2.5
對工程src -NEW -PyDev Module
新建的後綴名爲 .py 自動會切換到PyDev perspective 這個視圖下能夠更好的編輯。
hello world 代碼就一行 比java的少了不少。
簡單的安裝和Python代碼運行測試就是這樣。很簡單。都不須要duang duang duang的。
簡單的基礎運用代碼 能夠本身試試一下哦。
2015-03-03 Python 基礎知識
''' @author: 小帥丶 @todo: Python安裝使用第一步 Created on 2015-03-03 ''' #coding=utf-8 #Python for String----------------- str = "HelloWorld" print (str);#輸出字符串內容 print (str[0]);#索引爲0的內容 print (str[2:5]);#索引x到y的內容 包頭不包尾 print (str *2);#輸出2次內容 print (str + "Test");#輸出鏈接的內容 print ('---------------------------------------------'); #Python for List ------------------- list = ['abcd',786,2.23,'john',70.2] tinylist = [123,'john'] print (list); #輸出list print (list[0]); print (list[1:3]); print (list[2:]);#索引2開始 直到最後一個內容輸出 print (tinylist*2); print (list + tinylist); print ('---------------------------------------------'); #Python for 元組 tuple = ('abcd',786,2.23,'john',70.2) #tuple[0] = 'zxs' 元組是不能夠修改的 List能夠 tinytuple = (123,'john') print (tuple);#輸出元組 print (tuple[0]); print (tuple[1:3]); print (tuple[2:]); print (tinytuple*2); print (tuple + tinytuple); print ('---------------------------------------------'); #Python 元字典 dict = {} dict['one'] = "This is one" dict[2] = "This is two" tinydict = {'name':'john','code':6734,'dept':'sales'}#key value的關係 print (dict['one']);#輸出鍵爲 one的值 print (dict[2]);#輸出鍵爲 2的值 print (tinydict); print (tinydict.keys()); #輸出全部的鍵 print (tinydict.values());#輸出全部的值 print ('---------------------------------------------');
2015-03-04 Python 基礎知識
''' Created on 2015-3-4 @author: 小帥丶 ''' #Python for 運算 a = 21 b = 10 c = 0 c = a + b print ("Line 1 - Value of c is ",c);#加法 c = a - b print ("Line 2 - Value of c is ",c);#減法 c = a * b print ("Line 3 - Value of c is ",c);#乘法 c = a / b print ("Line 4 - Value of c is ",c);#除法 c = a % b print ("Line 5 - Value of c is ",c);#取餘 a = 2 b = 5 c = a**b print ("Line 6 - Value of c is ",c);#2的5次方 a = 9 b = 2 c = a//b print ("Line 7 - Value of c is ",c);#取整除 print ("--------------------------"); #Python for 比較運算符 a = 21 b = 10 c = 0 if(a == b): print ("Line 1 - a is equal to b"); else: print ("Line 1 - a is not equal to b"); if(a != b): print ("Line 2 - a is not equal to b"); else: print ("Line 2 - a is equal to b"); #if(a <> b): # print ("Line 3 - a is not equal to b"); #else: # print ("Line 3 - a is equal to b"); if(a < b): print ("Line 4 - a is less than b"); else: print ("Line 4 - a is not less than b"); if(a > b): print ("Line 5 - a is greater than b"); else: print ("Line 5 - a is not greater than b"); a = 5 b = 20 if(a <= b): print ("Line 6 - a is either less than b"); else: print ("Line 6 - a is not neither less than not b"); if(b >= a): print ("Line 7 - b is either greater than or equal to a"); else: print ("Line 7 - b is neither greater than nor equal to a"); print ("--------------Pyhton for 賦值運算符-------------------"); #Pyhton for 賦值運算符 a = 21 b = 10 c = 0 c = a + b print ("Line 1 - Value of c is ",c); c += a print ("Line 2 - Value of c is ",c); c *= a print ("Line 3 - Value of c is ",c); c /= a print ("Line 4 - Value of c is ",c); c = 2 c %= a print ("Line 5 - Value of c is ",c); c **= a print ("Line 6 - Value of c is ",c); c //= a print ("Line 7 - Value of c is ",c); print ("-------------Python位運算符----------") #Python for 位運算符 a = 60 #60 = 0011 1100 b = 13 #13 = 0000 1101 c = 0 c = a & b #12 = 0000 1100 print ("Line 1 -Value of c is ",c); c = a | b #61 = 0011 1101 print ("Line 2 -Value of c is ",c); c = a ^ b #49 = 0011 0001 print ("Line 3 -Value of c is ",c); c = ~a # -61= 1100 0011 print ("Line 4 -Value of c is ",c); c = a << 2 #240 = 1111 0000 print ("Line 5 -Value of c is ",c); c = a >> 2 #15 = 0000 1111 print ("Line 6 -Value of c is ",c); print ("----------Python邏輯運算符-----------"); #Python for 邏輯運算符 a = 10 b = 20 c = 0 if(a and b): print ("Line 1 - a and b are true"); else: print ("Line 1 - Either a is not true or b is not true"); if(a or b): print ("Line 2 - Either a is true or b is true or both are true"); else: print ("Line 2 - Neither a is true nor b is true"); a = 0 if(a and b): print ("Line 3 - a and b are true"); else: print ("Line 3 - Either a is not true or b is not true"); if(a or b): print ("Line 4 - Either a is true or b is true or both are true"); else: print ("Line 4 - Neither a is true nor b is true"); if not(a and b): print ("Line 5 - Either a is not true or b is not true or both are not true"); else: print ("Line 5 - a and b are true"); print ("---------Python成員運算符----------"); a = 10 b = 20 list = [1,2,3,4,5]; if (a in list): print ("Line 1 - a is available in the given list"); else: print ("Line 1 - a is not available in the given list"); if(b not in list): print ("Line 2 - b is not available in the given list"); else: print ("Line 2 - b is available in the given list"); a = 2 if(a in list): print ("Line 3 - a is available in the given list"); else: print ("Line 3 - a is not available in the given list"); print ("---------Python身份運算符--------"); #Python for 身份運算符 a = 20 b = 20 if(a is b): print ("Line 1 - a and b have same identity"); else: print ("Line 1 - a and b do not have same identity"); if(id(a)==id(b)): print ("Line 2 - a and b have same identity"); else: print ("Line 2 - a and b do not have same identity"); b = 30 if(a is b): print ("Line 3 - a and b have same identity"); else: print ("Line 3 - a and b do not have same identity"); if(a is not b): print ("Line 4 - a and b do not have same identity"); else: print ("Line 4 - a and b have same identity"); print("-----------Python運算符優先級-----------"); #Python for 運算符優先級 a = 20 b = 10 c = 15 d = 5 e = 0 e = (a + b) * c / d print ("Value of (a+b)*c/d is",e); e = ((a + b) * c) / d print ("Value of ((a+b)*c)/d is", e); e = (a + b) * (c / d); print ("Vlaue of (a+b)*(c/d) is", e); e = a + (b * c) / d; print ("Value of a + (b * c)/d is ", e);
#2015-03-04代碼運行結果 Line 1 - Value of c is 31 Line 2 - Value of c is 11 Line 3 - Value of c is 210 Line 4 - Value of c is 2.1 Line 5 - Value of c is 1 Line 6 - Value of c is 32 Line 7 - Value of c is 4 -------------------------- Line 1 - a is not equal to b Line 2 - a is not equal to b Line 4 - a is not less than b Line 5 - a is greater than b Line 6 - a is either less than b Line 7 - b is either greater than or equal to a --------------Pyhton for 賦值運算符------------------- Line 1 - Value of c is 31 Line 2 - Value of c is 52 Line 3 - Value of c is 1092 Line 4 - Value of c is 52.0 Line 5 - Value of c is 2 Line 6 - Value of c is 2097152 Line 7 - Value of c is 99864 -------------Python位運算符---------- Line 1 -Value of c is 12 Line 2 -Value of c is 61 Line 3 -Value of c is 49 Line 4 -Value of c is -61 Line 5 -Value of c is 240 Line 6 -Value of c is 15 ----------Python邏輯運算符----------- Line 1 - a and b are true Line 2 - Either a is true or b is true or both are true Line 3 - Either a is not true or b is not true Line 4 - Either a is true or b is true or both are true Line 5 - Either a is not true or b is not true or both are not true ---------Python成員運算符---------- Line 1 - a is not available in the given list Line 2 - b is not available in the given list Line 3 - a is available in the given list ---------Python身份運算符-------- Line 1 - a and b have same identity Line 2 - a and b have same identity Line 3 - a and b do not have same identity Line 4 - a and b do not have same identity -----------Python運算符優先級----------- Value of (a+b)*c/d is 90.0 Value of ((a+b)*c)/d is 90.0 Vlaue of (a+b)*(c/d) is 90.0 Value of a + (b * c)/d is 50.0
Python for 數字 2015-03-09
import math import random for letter in 'Python': if letter =='h': pass print ('This is pass block'); print ('Current Letter:',letter); print ('Good bye!'); print("------Random-----"); a = -10 b = 4.1 x = 1 y = 2 print ("值爲:",a,"絕對值爲:",abs(a));#返回絕對值 print (math.ceil(b));#向上取整 print (math.exp(1)); print (math.fabs(-10));#返回絕對值 print (math.floor(4.9));#向下取整 print (math.log(4,2));#天然數的對數 print (math.log10(100));#基數爲10 print (math.pow(2, 2)); print (round(12.334,2)); print (math.sqrt(4)); print ("隨機數",random.choice(range(10)));#指定隨機數範圍 print (random.randrange(100,1000,1));#開始範圍 結束範圍 遞增基數 random.seed(10) print (random.random()); list = [20,16,10,5]; random.shuffle(list); print (list); print (random.uniform(5,10)); print (math.acos(1)); print (math.asin(1)); print (math.atan(1)); print (math.atan2(5, 5)); print (math.cos(3)); print (math.hypot(3, 2));#sqrt(3*3 +2*2) print (math.sin(3)); print (math.sin(math.pi/2)); print (math.tan(3)); print (math.tan(math.pi/4)); print (math.degrees(2*math.pi));#弧度轉爲角度 print (math.degrees(math.pi)); print (math.degrees(math.pi/2)); print (math.degrees(math.pi/4)); print (math.radians(0)); print (math.radians(math.pi)); print (math.radians(math.pi/2)); print (math.radians(math.pi/4));
2015-03-10 code for python
var1 = 'Hello World!'; var2 = 'Python Programming'; print (var1[0]); print (var2[1:5]); print ('--------------'); #更新字符串 var1 = 'Hello World' print (var1[:6]+'Python'); print ('--------------'); #List list1 = [123,'xyz',7899] list2 = [456,'abc'] print (len(list1)); print (len(list2)); print ('--------------'); #List list() aTuple = (123,'xyz','zara','abc'); aList = list(aTuple); print (aList); print ('--------------'); #List append() aList = [123,'xyz','zara','abc'] aList.append(2009); print (aList); print ('--------------'); #List count aList = [123,'xyz','zara','abc',123] print (aList.count(123)); print (aList.count('zara')); print ('--------------'); #List extend aList = [123,'xyz','zara','abc',123] bList = [2009,'manni']; aList.extend(bList); print (aList); print ('--------------'); #List index aList = [123,'xyz','zara','abc'] print (aList.index('xyz')); print (aList.index('zara')); print ('--------------'); #List insert aList = [123,'xyz','zara','abc'] aList.insert(3, 2009); print (aList); print ('--------------'); #List pop aList = [123,'xyz','zara','abc'] print (aList.pop()); print (aList.pop(2)); print ('--------------'); #List remove aList = [123,'xyz','zara','abc','xyz'] aList.remove('xyz'); print (aList); aList.remove('abc'); print (aList); print ('--------------'); #List reverse() aList = [123,'xyz','zara','abc','xyz'] aList.reverse(); print (aList); print ('--------------'); #List sort aList = [123,'xyz','zara','abc','xyz'] aList.sort(); print (aList); print ('--------------');