PIXNET Logo登入

wsunccake的隨手記事

跳到主文

歡迎光臨wsunccake在痞客邦的小天地

部落格全站分類:不設分類

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 6月 22 週四 201704:02
  • 誤闖 Python Lamdba 的小陷阱

funs = []
for c in range(3):
    a = lambda x: x + c
    funs.append(a)
(繼續閱讀...)
文章標籤

wsunccake 發表在 痞客邦 留言(0) 人氣(5)

  • 個人分類:Python
▲top
  • 6月 27 週六 201514:59
  • PyCharm (2) - 編輯檔案

Option 或 Alt 鍵圖像
先在 project1 目錄下建立 Person.py 和 test1.py 兩個檔案, 內容如下
Person.py
class Person(object):
    def __init__(self, name):
        self.setName(name)
(繼續閱讀...)
文章標籤

wsunccake 發表在 痞客邦 留言(0) 人氣(125)

  • 個人分類:Python
▲top
  • 6月 27 週六 201509:55
  • PyCharm (1) - 開啟檔案

pycharm_01.png
執行 PyCharm
PyCharm 的開始畫面

當有建立過 project 後, PyCharm 的開始畫面
(繼續閱讀...)
文章標籤

wsunccake 發表在 痞客邦 留言(0) 人氣(2,095)

  • 個人分類:Python
▲top
  • 1月 10 週五 201410:28
  • 簡易Python unittest範例

import unittest # 載入unittest
class Person: # 要測試的class
    def __init__(self, name):
        self.name = name
        self.age = 10
    def getName(self):
        return self.name
    def setAge(self, age):
        self.age = age
class TestPerson(unittest.TestCase):
    def setUp(self): # 每個測試初始化
        print 'init',
        self.p = Person('John')
    def test_getName(self): #要測試的功能, 名稱需test開頭
        print 'test getNme',
        self.assertEqual(self.p.getName(), 'John' )
    def test_setAge(self):
        print 'test setAge',
        self.assertEqual(self.p.age, 10 )
        self.p.setAge(18)
        self.assertNotEqual(self.p.age, 10 )
    def tearDown(self): # 每個測試結束
        print 'final'
(繼續閱讀...)
文章標籤

wsunccake 發表在 痞客邦 留言(0) 人氣(1,151)

  • 個人分類:Python
▲top
  • 7月 20 週三 201122:01
  • 第一個wxPython程式

hello2.PNG



import wx
class HelloFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "HelloFrame", size=(200, 100))
        panel = wx.Panel(self, -1)  #初始化frame
        wx.StaticText(panel, -1, "Hello World", pos=(60, 25)) #設定文字 
        
if __name__ == '__main__':
    app = wx.PySimpleApp()  #建立simple app
    frame = HelloFrame()       #產生自訂frame
    frame.Show(True)            #顯示frame
    app.MainLoop()                #執行app




(繼續閱讀...)
文章標籤

wsunccake 發表在 痞客邦 留言(0) 人氣(1,028)

  • 個人分類:Python
▲top
1

個人資訊

wsunccake
暱稱:
wsunccake
分類:
不設分類
好友:
累積中
地區:

熱門文章

  • (2,095)PyCharm (1) - 開啟檔案
  • (1,028)第一個wxPython程式
  • (901)RHEL 7.1 安裝 rpcapd
  • (17)MongoDB 的基本操作
  • (7)Install Ruby 2.1.3 from srource code in Linux

文章分類

  • Linux (21)
  • Python (5)
  • MacOS (4)
  • Ruby (2)
  • 未分類文章 (1)

最新文章

  • kernel panic - failed to execute / init
  • CentOS 上安裝 screenfetch
  • CentOS 上安裝 cowsay
  • MongoDB 增加 document
  • MongoDB 備份
  • MongoDB 的基本操作
  • 使用 docker 安裝 MongoDB
  • CentOS 7 安裝 MongoDB
  • Gradle 建立 Java, Groovy application
  • CentOS 以 Selenium RC 方式執行 RobotFramework

最新留言

    動態訂閱

    文章精選

    文章搜尋

    誰來我家

    參觀人氣

    • 本日人氣:
    • 累積人氣: