ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 必记代码 > ### 99乘法表 ~~~ for i in range(1,10): for y in range(1,i+1): msg = '{0}*{1}={2}'.format(i,y,i*y) print(msg,end='\t') print() ~~~ > ### 冒泡排序 ![](https://img.kancloud.cn/15/43/1543c0b97237bb55063e033959706ca0_801x315.gif) ~~~ a = [9,2,3,1,6,7,0] # 确定循环次数为 列表长度-1次 times = len(a) -1 while times > 0: for i in range(times): if a[i] < a[i+1]: a[i],a[i+1]=a[i+1],a[i] times = times -1 print(a) ~~~ > ### 自动化测试用例 ~~~ from selenium import webdriver from time import sleep import unittest class mytest(unittest.TestCase): def setUp(self): self.d = webdriver.Chrome() self.d.get('网址') def tearDown(self): self.d.close() self.d.quit() def test_case_001(self): self.d.find_element_by_css_selector('CSS定位表达式').send_keys('username') self.d.find_element_by_xpath('Xpath定位表达式').send_keys('password') self.d.find_element_by_css_selector('CSS定位表达式').click() sleep(1) login_msg = self.d.find_element_by_id('ID').text self.assertIn('预期结果',login_msg) if __name__ == '__main__': unittest.main() ~~~