發表文章

目前顯示的是 2019的文章

Ubuntu 18.04.1 mysql password settings, and can be set without sudo login

Description: After installing Ubuntu 18.04.1 , you cannot execute the mysql command as a user.  You must use sudo to execute the mysql directive, and any php program may not be able to connect to mysql. Step1: Login to the mysql interface example: Sudo mysql -uroot -p Enter password: [press Enter directly] Step2:  Modify the account management mode and change password mysql>  Use mysql; mysql>  Update user SET plugin='mysql_native_password' WHERE User='root'; mysql>  Update user set authentication_string=password('root new password') where user='root'; mysql>  Flush privileges; Step3:  After logging out, you can use the following mysql command without adding sudo

Hide black console window

Step1: First package according to common procedures Need pyinstaller example: First reach the location of this scripts cd C:\Python27\Scripts Then enter pyinstaller -F D:\Wayne\file.py --distpath D:\Wayne At this time, the folder will be generated on the desktop. build, dist There is also a protagonist of "Archive.spec" Open "Profile.spec" with Notepad One of them is like this Exe = EXE(pyz,           A.scripts,           A.binaries,           A.zipfiles,           A.datas,           [],           Name='my file',           Debug=False,           Bootloader_ignore_signals=False,           Strip=False,           Upx=True,           Runtime_tmpdir=None,           Conso...

Ubuntu server 安裝 teamviewer 和使用 teamviewer

Step1: create a folder to save, download the TeamViewer installation package mkdir ~/downloads/  cd ~/downloads/  wget https://download.teamviewer.com/download/teamviewer_i386.deb Step2: TeamViewer installation package sudo dpkg -i teamviewer_i386.deb cd /opt/teamviewer/tv_bin Teamviewer --setup console #Set the startup mode to console startup Teamviewer --daemon restart #restart teamview service Sudo teamviewer --passwd 112358 #Set password Teamviewer --info #teamview # View id If you get an error, and the content is as follows: Sudo apt-get install libdbus-1-3:i386 libasound2:i386 libexpat1:i386 libfontconfig1:i386 libfreetype6:i386 libjpeg62:i386 libpng12-0:i386 libsm6:i386 libxdamage1:i386 libxext6:i386 libxfixes3:i Then execute the command: sudo apt-get update sudo apt-get install -f These two commands are fine. After this, it will not succeed. When you log in, you will get an error. Failed to start session You can use Ctrl + Alt +F1 to enter the c...

python 測試框架工具

Python的測試框架 Unit frameworks單元測試框架 Framework unittest   - python自帶的單元測試庫,開箱即用 unittest2   - 加強版的單元測試框架,適用於Python 2.7以及後續版本 pytest   - 成熟且功能強大的單元測試框架 plugincompat   - pytest的執行及兼容性插件 nosetests   - 讓python測試更容易一點 slash   - python實現的單元測試框架 Extension proboscis   - 仿TestNG擴展了unittest模塊以及Nose的功能 grail   -可以讓你一步一步編寫測試用例的庫 Testify   - 單元測試框架,提供了加強型夾具,用例切割並行運行,testrunner高亮及詳盡的日誌和報告功能 trial   - unittest模塊的擴展,提供了命令行的testrunner工具以及代碼覆蓋率的整合,跟鼻差不多 subunit   - 提供了unittest在另一個進程執行用例並彙總測試數據的能力 testresources   - 提供了多用例間管理測試數據的機制,兼容unittest testtools   - 為Twisted和Bazaar提供的unittest擴展 Sancho   - 運行用例,並為失​​敗的用例提供報告,但僅限於此 zope.testing   - testrunner,提供了不錯的debuge能力,並且集成了代碼覆蓋率。可以跟zope項目使用,也可以用在非zope項目上 pythoscope   - 自動或半自動為遺留的python系統創建測試用例的工具 testlib   - 更強大的unittest,更多的斷言,支持模塊級的設置/拆解,跳過測試等... dutest  ...

openpyxl

OpenPyXL 模組:基本功能操作 l     在命令提示字元輸入 pip install openpyxl ,下載並安裝 OpenPyXL 模組。 l     開啟 Excel 檔與工作表: import openpyxl #  本書範例檔 example.xlsx 在目前工作目錄 #  此 Workbook 物件代表 Excel 檔 aBook = openpyxl.load_workbook("example.xlsx") print(type(aBook))  à  <class 'openpyxl.workbook.workbook.Workbook'> print(aBook.sheetnames)  à  ['Sheet1', 'Sheet2', 'Sheet3'] #  此 Worksheet 物件代表工作表 aSheet = aBook["Sheet3"] print(type(aSheet))  à  <class 'openpyxl.worksheet.worksheet.Worksheet'> print(aSheet)  à  <Worksheet "Sheet3"> print(aSheet.title)  à  Sheet3 bSheet = aBook.active print(bSheet)  à  <Worksheet "Sheet1"> l     取得 Excel 檔工作表的儲存格: import openpyxl #  本書範例檔 example.xlsx 在目前工作目錄 aBook = openpyxl.load_workbook("example.xlsx") aSheet = aBook["Sheet1"] # Cell 物件取得儲存格的方法一 aCell = aSheet["B1"] print(aCell)  à  <Cell 'Sheet1'.B1> print("Row...

Selenium模組

l     在命令提示字元輸入 pip install selenium ,下載並安裝 Selenium 模組。 l     以下以 Google Chrome 瀏覽器為例,下載 chromedriver : ChromeDriver -WebDriver for Chrome l     WebDriver 物件與 WebElement 物件範例: from selenium import webdriver chromedriverPath = r"C:\Users\Timmy\Documents\Python\chromedriver.exe" driver = webdriver.Chrome(chromedriverPath) print(type(driver)) à  <class 'selenium.webdriver.chrome.webdriver.WebDriver'> driver.get("http://inventwithpython.com") #  參考下列 WebDriver 物件方法說明 element = driver.find_element_by_class_name("display-3") print(type(element)) à  <class 'selenium.webdriver.remote.webelement.WebElement'> #  參考下列 WebElement 物件屬性或方法說明 print(element.text)  à  Learn to Program. For Free. l     WebDriver 物件方法說明- find_element_* 、 find_elements_* : WebDriver 物件方法 find_element_* 與 find_elements_* 皆返回 WebElement 物件,前者尋找比對符合的第一個元素,後者尋找比對符合的所有元素串列;如果找不到,會丟出 NoSuchElement 例外。 返回元素標籤為 tes...