Python 字符串替换
查找固定字符串并替换
使用字符串对象的 .replace()
方法
s = 'a---c'
s.replace('-','') # 'ac'
s.replace('--','-') # 'a--c'
正则表达式查找并替换
使用 re.sub()
import re
s = 'a---c'
re.sub(r'[-]+', '-', s) #'a-c'
更多 re.sub 用法可参考 Python 使用正则 re.sub 做字符串复杂替换
使用字符串对象的 .replace()
方法
s = 'a---c'
s.replace('-','') # 'ac'
s.replace('--','-') # 'a--c'
使用 re.sub()
import re
s = 'a---c'
re.sub(r'[-]+', '-', s) #'a-c'
更多 re.sub 用法可参考 Python 使用正则 re.sub 做字符串复杂替换
AWS REST API 要能正常跨域请求,在 API Gateway,Lambda Function 都需要额外的配置。
⚠️注意:先在类似 Postman 工具里测试 API 已经能正常执行,确认可以返回正确的结果。
使用 ListUsers
API
举例:
users = cognito_idp.list_users(UserPoolId=userpool_id,Filter='email="'+email+'"')
python -m venv
与 pip install -r requirements.txt
即可重建相同环境。Python 3.3 之前可使用
virtualenv
,参考 用 VirtualEnv 为项目创建独立运行环境。
function get_webkit_version() {
var ua = navigator.userAgent;
if (/webkit\/(.*?) /gmi.test(ua)) {
return parseFloat(/webkit\/(.*?) /gmi.exec(ua)[1]);
}
else {
return null;
}
}
修改 Ruby 的 filehandler.rb 文件,
路径类似:
“/Users/your-name/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/webrick/httpservlet/filehandler.rb”
Liquid 如何创建一个空的数组,
{% assign arr = '' | split: ',' %}
小提示:两个数组的连接,使用 concat
过滤器
相关知识
Liquid 如何向数组增加一个元素,
liquid 语言本身是没有此功能函数(过滤器),但 Jekyll 提供了一个方法:push
使用方式:{{ page.tags | push: "Spokane" }}
扩展知识: Jekyll 提供的过滤器清单
将两个字符串连接在一起,Liquid 不能直接使用连接符号,例如其它语言里的“+”加号。
而是使用 append
这个 filter。
举例:
{% assign text = "a" | append: "b" %}
{% assign x = 'abc' %}
{% assign y = 'def' %}
{% assign z = x | append: ' - ' | append: y %}
{{ z }}
output: abc - def
嗨,我是芦苇Z。本文是 macOS新手入门系列。
在日常使用Mac时,快速锁定屏幕是保护隐私和数据安全的重要习惯。无论是暂时离开座位,还是结束工作,一键锁屏都能让我们的Mac更加安全。今天就来聊聊macOS中几种快速锁屏的方法。