Time of Update: 2015-08-11
標籤:1、匯入MySQL模組
Time of Update: 2015-08-14
標籤:keyerror windowserror error 2 中文路徑 中文字串 python Python在執行過程中,常常出現不能讀取中文路徑名,表現為讀取的路徑是空或者直接報錯(WindowsError: [Error
Time of Update: 2015-08-16
標籤:python 結構 這一節我們聊聊模組結構模組的結構非常中藥,它可以讓維護人員一眼就看懂代碼的分布,搞懂一部分代碼的意思1.文檔python特別的留了一個__doc__的動態變數來讓外界讀取對象的文檔字串2.結構我們舉一個例子來說明:#/usr/bin/env python 起始行'this is a test module'#模組文檔(文檔字串)import sys#引用模組import
Time of Update: 2015-08-16
標籤:python 記憶體管理 * 變數無需事先聲明* 變數無需指定類型* 程式員不用關係記憶體管理* 變數名會被回收* del可以直接釋放資源1.python使用的是引用調用,而不是值調用,他使用的回收演算法是引用計數演算法,我下面舉兩個例子x = 4y = 4aList = [1, 2, 3]bList = [1, 2, 3]print(x is y)print(x ==
Time of Update: 2015-08-14
標籤:安裝SALT時,需要這樣作,公司有一批REDHAT5的,弄起來。。。 然後卻是:Missing Dependency: python(abi) = 2.6 is needed by package rpm -q --provides python | grep abipython(abi) =
Time of Update: 2015-08-15
標籤: 1. 定義一個函數: 1)必須以def開頭 2)參數之間用,隔開 3)函數的內容以冒號:開始,並且縮排 4)不帶運算式的return,相當於返回None
Time of Update: 2015-08-13
標籤:所有測試語句基於Python 2.7.3 , Ubuntu 12.04自學Python,如果哪裡說的不恰當,還請指正。謝謝。樣本絕大部分來自部落格園vamei的python教程 1.迴圈對象#!/usr/bin/env python#coding=UTF-8#包含一個next()方法 每次迴圈調用next()#直到StopIteration異常出現 停止調用next()方法f = open(‘test.txt‘)for line in f: print line
Time of Update: 2015-08-12
標籤:量化分析師的Python日記【第1天:誰來給我講講Python?】薛昆Kelvin 優礦 001 號員工2015-01-28
Time of Update: 2015-08-13
標籤:?? 介紹?? 輸入/輸出?? 注釋?? 操作符?? 變數與賦值?? Python 類型?? 縮排?? 迴圈與條件?? 檔案?? 錯誤?? 函數?? 類?? 模組2.3 注釋 普通注釋 和大部分指令碼及Unix-shell 語言一樣,Python 也使用 # 符號標示注釋,從 # 開始,直到一行結束的內容都是注釋。 >>> # one comment
Time of Update: 2015-08-14
標籤:整體思想: 完全按照自己的想法來寫的,首先寫模板檔案,然後開啟模板檔案,對模板進行字串格式化處理,最後再將格式化後的字串儲存到新的檔案裡面。如有更好的想法,歡迎交流。 將相似性很高的代碼寫模板檔案(widget_template.txt): # -*- coding: UTF-8 -*-#!/usr/bin/env python#-----------------------------------
Time of Update: 2015-08-12
標籤:wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz tar zxf Python-2.7.3.tgz cd Python-2.7.3 ./configure –prefix=/usr/local/python27 make make install ln -sf
Time of Update: 2015-08-13
標籤:python 檔案 今天我們來說說檔案,以及跟檔案有關的內建函數open和file首先我們在python的根目錄下建一個名為“123”的txt文字檔檔案裡面我們輸入一些文本我們把建立檔案與原始碼都放到python根目錄下面下面我們來看看代碼:handler=open("123.txt")#由於把檔案跟原始碼建立在python的根目錄,
Time of Update: 2015-08-11
標籤:一,兩個函數的文檔: 1,time.time(): time.time() Return the time in seconds since the epoch as a floating point number. Note that even though the time is always returned as a floating point number, not all systems provide time with a better precision
Time of Update: 2015-08-11
標籤:注釋 python 在python裡面,使用“#”號表示注釋的開始,一整行到結束就是注釋,他的主要作用提示這段代碼究竟有什麼用處print("---------歡迎來到猜數位地方,請開始---------")#輸出提示guess=int(input("*數字區間0-100,請輸入你猜的數字:"))#讀取輸入,然後賦值print(guess)#列印輸入
Time of Update: 2015-08-10
標籤:character declared february details python SyntaxError: Non-ASCII character ‘\xe6‘ in file ./1.py on line 3, but no encoding declared; see
Time of Update: 2015-08-10
標籤:os模組(2)介紹os常量路徑判斷路徑屬性路徑變換檔案屬性相同檔案介紹- os.path模組,主要處理路徑操作,包含了各種處理檔案和檔案名稱的方法。os.path常量os.path.sep 路徑分隔字元 (Unix為 /,Win為 \\)os.path.pathsep 多個路徑間的分隔字元,多用於環境變數 (Unix為 :, Win為 ;)os.path.extsep 尾碼名符號 一般為 .路徑os.path.split 分割路徑為目錄名和檔案名稱os.path.dirname
Time of Update: 2015-08-09
標籤:載入背景音樂播放背景音樂(設定單曲迴圈)我方飛機誕生interval = 0while True:if 使用者是否點擊關閉按鈕退出程式breakinterval += 1if interval = 50:interval = 0小飛機誕生小飛機移動一個位置螢幕重新整理if 使用者滑鼠產生移動:我方飛機中心位置 = 使用者滑鼠位置螢幕重新整理if 我方飛機與小飛機發生肢體衝突我方掛,播放撞擊音樂修改我方飛機圖案列印 Game
Time of Update: 2015-08-09
標籤:–Code——————————————————————-print("----------第一個小遊戲----------")temp = input("猜一下我現在心裡在想那個數字")guess =
Time of Update: 2015-08-09
標籤: 任何序列都可以引用其中的元素(item).下面的內建函數(built-in function)可用於列表(表,定值表,字串)#s為一個序列len(s)返回:
Time of Update: 2015-08-10
標籤:python exec exec語句用來執行儲存在字串或檔案中的Python語句。例如,我們可以在運行時產生一個包含Python代碼的字串,然後使用exec語句執行這些語句。下面是一個簡單的例子。>>> exec ‘print "Hello World"‘Hello World注意例子中exec語句的用法和eval_r(), execfile()是不一樣的.