Python learning notes (simple excel operations) and python learning notes

Source: Internet
Author: User

Python learning notes (simple excel operations) and python learning notes

The goal is to design an interface automation testing framework.

Use Cases are written in excel and built using python's pyunit

The excel processing module has been installed.

This simple application

Create an excel file named “testcase.xls in advance"

The operation code is as follows:

1 #! /Usr/bin/env python 2 #-*-coding: utf_8-*-3 4 import xlrd 5 6 def read_testcase (): 7 workbook = xlrd. open_workbook (r 'e: \ work \ python case \ learn \ testcase.xls ') 8 # Open the excel file 9 print workbook according to the path. sheet_names () 10 # print all sheet names 11 table = workbook. sheet_by_name ('login') 12 # Get the corresponding sheet content through the sheet name 13 # You can also get the first sheet14 # table = workbook in order. sheets () [0] 15 print table. row_values (0) 16 print table. row_values (1) 17 print table. row_values (2) 18 print table. row_values (3) 19 # obtain the entire row of data (array) 20 print table by the number of rows. col_values (0) 21 print table. col_values (1) 22 print table. col_values (2) 23 # obtain column data (array) 24 print table by column number. cell (0, 0 ). value25 print table. cell (0, 1 ). value26 print table. cell (0, 2 ). value27 print table. cell (1, 0 ). value28 print table. cell (1, 1 ). value29 print table. cell (1, 2 ). value30 print table. cell (2, 0 ). value31 print table. cell (2, 1 ). value32 print table. cell (2, 2 ). value33 print table. cell (3, 0 ). value34 print table. cell (3, 1 ). value35 print table. cell (3, 2 ). value36 # retrieve data by Cell 37 38 if _ name _ = '_ main _': 39 read_testcase ()

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.