-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNote_string.py
More file actions
45 lines (35 loc) · 783 Bytes
/
Note_string.py
File metadata and controls
45 lines (35 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
# encoding: utf-8
# product.py
# product
# Created by txooo on 2018/11/19
# Copyright © 2018 txooo. All rights reserved.
import re
# 分割
s1 = 'adnm|sdjka|sa|123'
s2 = 'wqewq'
print(s1.split('|'))
print(s2.split('|'))
# 通过字符集分割
r1 = re.split('[a|s]', s1)
print(r1)
request_url = 'https://www.baidu.com/'
if request_url[len(request_url) - 1] == '/':
href_prefix = request_url[:len(request_url) - 1]
else:
href_prefix = request_url
print(href_prefix)
# 去除空格
s3 = ' sfdasf '
print(s3)
print(s3.strip())
print(s3)
s4 = 'http://sfdasf/'
print(s4)
print(s4.strip('/'))
print(s4)
bstr = b'www'
test_str = b'www.baidu.com'
print(test_str.find(bstr) != -1)
url = 'http://sjh.baidu.com'
print(url.startswith('http://sjh.baidu.com'))