码迷,mamicode.com
首页 > 编程语言 > 详细

Python 字符串正则处理实例

时间:2017-12-18 19:08:24      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:pos   move   UI   for   分析   9.1   www   app   odi   

#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 ‘\n==============‘    
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

  

Python 字符串正则处理实例

标签:pos   move   UI   for   分析   9.1   www   app   odi   

原文地址:http://www.cnblogs.com/liuliu-word/p/8058099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!