zoukankan      html  css  js  c++  java
  • Python 字符串正则处理实例

    #coding:utf-8
    
    
    '''
    Created on 2017��9��6��
    
    @author: li.liu
    '''
    
    from selenium import webdriver
    from selenium.webdriver.common.action_chains import ActionChains
    import os
    import time
    import re
    
    url='http://101.37.179.183'
    #url='http://www.baidu.com'
    
    '''
    xpath='//*[@id="header"]/div[4]/span[1]/a'
    xpath1='//*[@id="header"]/div[4]/span[2]/a'
    driver=webdriver.Chrome()
    driver.get(url)
    #elem=driver.find_element_by_xpath(xpath)
    #ActionChains(driver).move_to_element(elem).perform()
    #time.sleep(1)
    print driver.find_element_by_xpath(xpath1).is_selected()
    print 1
    driver.quit()
    
    try:
        driver.find_element_by_xpath(xpath1).click()
        
    except:
        elem=driver.find_element_by_xpath(xpath)
        ActionChains(driver).move_to_element(elem).perform()
        driver.find_element_by_xpath(xpath1).click()
    print 1
    
    n='n'
    m='m'
    t={n:[1,2],m:[3,4,5]}
    
    l='l'
    t[l]=[]
    t[l].append(6)
    t[l].append(7)
    t[l].extend(t[n])
    
    print type(t)
    for i in t:
        print i,t[i]
    
    
    t[l]=[]
    print '
    =============='    
    for (d,k) in t.items():
        print d,k
    '''
    '''
    a=1
    b=2
    b=a+b
    a=b-a
    b=b-a
    print a,b
    
    def t(*t):
        print type(t)
        
    def h(**t):
        print t
    t(1,2)
    h(a={},b=2,c=3)
    
    print '需求分析'
    print ''
    '''
    
    c=0
    
    '''
    for i in a:
        try:
            print int(i)
            c+=1
        except:
            pass
    print c
    '''
    
    a='abcd1.2dbdf4dd32da2dfs9df'
    s=re.findall('d', a)
    t=''
    for i in s:
        t=t+i
    print t
    
    s=re.compile('D')
    c=re.sub(s,'',a)
    print c
    

      

  • 相关阅读:
    leetcode算法题基础(五)双指针(一)27 题 移除元素
    kata-shim: Setctty set but Ctty not valid in child: unknown.
    kata-runtime mount
    UVa1636 Headshot
    HDU1150 Machine Schedule
    POJ 1273 Drainage Ditches
    SPOJ GSS1 Can you answer these queries I
    POJ 1840 Eqs
    POJ2001 Shortest Prefixes
    HDU 2795 Billboard
  • 原文地址:https://www.cnblogs.com/liuliu-word/p/8058099.html
Copyright © 2011-2022 走看看