第三方API返回以base64编码的“ QR码图像”,
我需要将该图像保存到“用户相册”中。
该阵营本地取入一滴维护者失踪了,所以没有人回答Github上的问题,
createFile从阵营原生取入一滴文件未正常工作(不保存图像到相册)
import fetch_blob from 'react-native-fetch-blob';
// json.qr variable are return from API
const fs = fetch_blob.fs
const base64 = fetch_blob.base64
const dirs = fetch_blob.fs.dirs
const file_path = dirs.DCIMDir + "/some.jpg"
const base64_img = base64.encode(json.qr)
fs.createFile(file_path, base64_img, 'base64')
.then((rep) => {
alert(JSON.stringify(rep));
})
.catch((error) => {
alert(JSON.stringify(error));
});
Run Code Online (Sandbox Code Playgroud)
因为我fetch的API没有CORS标头,
所以我无法在Debug JS Remotely
Chrome中对其进行调试会阻止该请求的发生,
我必须在我的Android手机上运行它才能使其正常运行
(在真实手机上没有CORS控件)
我打算使用剪贴板保存base64字符串,
并在我的代码中对其进行硬编码,
以调试react-native-fetch-blob createFileAPI的问题
我试图7从数组中删除所有s:
a = [1,2,3,4,5,7,7,7,7,7,7,7,7,7,9,10,11,12,13]
Run Code Online (Sandbox Code Playgroud)
我做了:
a.each_with_index do |item, index|
if item == 7
a.delete_at(index)
end
end
a # => [1, 2, 3, 4, 5, 7, 7, 7, 7, 9, 10, 11, 12, 13]
Run Code Online (Sandbox Code Playgroud)
这怎么发生的?
我希望拆分号码与另一个角色.
例
输入:
we spend 100year
Run Code Online (Sandbox Code Playgroud)
输出:
we speed 100 year
Run Code Online (Sandbox Code Playgroud)
输入:
today i'm200 pound
Run Code Online (Sandbox Code Playgroud)
产量
today i'm 200 pound
Run Code Online (Sandbox Code Playgroud)
输入:
he maybe have212cm
Run Code Online (Sandbox Code Playgroud)
输出:
he maybe have 212 cm
Run Code Online (Sandbox Code Playgroud)
我试过re.sub(r'(?<=\S)\d', ' \d', string)和re.sub(r'\d(?=\S)', '\d ', string),这是行不通的.
我想要匹配字符串:
what.are you doing?
Run Code Online (Sandbox Code Playgroud)
匹配在一个点后面有一些字母 并替换"." 用"."
结果如:
what. are you doing?
更多的例子
输入
uh....i don't know
Run Code Online (Sandbox Code Playgroud)
产量
uh.... i don't know
Run Code Online (Sandbox Code Playgroud)
输入
do you know....that thing?
Run Code Online (Sandbox Code Playgroud)
产量
do you know.... that thing?
Run Code Online (Sandbox Code Playgroud)