测试浏览器:Chrome版本:52.0.2743.116
这是一个简单的javascript,用于从本地打开图像文件,如'C:\ 002.jpg'
function run(){
var URL = "file:///C:\002.jpg";
window.open(URL, null);
}
run();
Run Code Online (Sandbox Code Playgroud)
这是我的示例代码. https://fiddle.jshell.net/q326vLya/3/
请给我任何合适的建议.
我在我的OSX上有一个PHP项目,它是在latin1 -encoding中.现在我需要将文件转换为UTF8.我不是一个shell编码器,我尝试过从互联网上找到的东西:
mkdir new
for a in `ls -R *`; do iconv -f iso-8859-1 -t utf-8 <"$a" >new/"$a" ; done
Run Code Online (Sandbox Code Playgroud)
但这不会创建目录结构,它会让我在运行时加载错误.任何人都可以拿出整洁的解决方案吗?
我以列表的形式获得order_by字段.我想用django orm通过多个字段order_by.列表如下:
orderbyList = ['check-in','check-out','location']
Run Code Online (Sandbox Code Playgroud)
我写的查询是这样的:
modelclassinstance.objects.all().order_by(*orderbyList)
Run Code Online (Sandbox Code Playgroud)
我在列表中所期待的一切都是动态的.我没有预先设定的数据集.有人可以告诉我如何用这个写一个django ORM吗?
我正在尝试写入文件.我阅读了文件的全部内容,现在我想根据文件中的一些单词更改文件的内容.但是当我检查文件的内容时,它仍然是相同的,并且没有改变.这就是我用过的东西
if strings.Contains(string(read), sam) {
fmt.Println("this file contain that word")
temp := strings.ToUpper(sam)
fmt.Println(temp)
err := ioutil.WriteFile(fi.Name(), []byte(temp), 0644)
} else {
fmt.Println(" the word is not in the file")
}
Run Code Online (Sandbox Code Playgroud) 我有一个id列表:
(1, 2, 3, 6, 7)
Run Code Online (Sandbox Code Playgroud)
还有一张桌子:
id | anothercolumn
------------------
1 | NULL
2 | foo
4 | bar
5 | NULL
6 | NULL
Run Code Online (Sandbox Code Playgroud)
我想从列表中检索不是我的表的ID的值.
预期结果:
3, 7
Run Code Online (Sandbox Code Playgroud)
我试过这样的事情:
SELECT i
WHERE i IN (1, 2, 3, 6, 7)
AND i NOT IN (SELECT id FROM mytable);
Run Code Online (Sandbox Code Playgroud)
但这不是一个有效的MySQL查询(一个FROM是必需的).
还有这种可能性:
SELECT i
FROM (
SELECT 1 AS i
UNION SELECT 2
UNION SELECT 3
UNION SELECT 6
UNION SELECT 7 ) AS mylistofids
LEFT JOIN …Run Code Online (Sandbox Code Playgroud) 我想知道什么是最好的写作方式URL.py.我试图以这种方式获得索引:www.example.comwith (r'',index).但是当我尝试时r'',网站上的所有页面都会进入主页.
我的一部分url.py:
(r'^index',homepages),
(r'',homepages),
Run Code Online (Sandbox Code Playgroud)
谢谢 :)
我正在尝试使reCAPTCHA与严格的内容安全策略一起工作.这是我的基本版本,它可以正常工作:
HTML
<script src='//www.google.com/recaptcha/api.js' async defer></script>
Run Code Online (Sandbox Code Playgroud)
HTTP标头
Content-Security-Policy: default-src 'self'; script-src 'self' www.google.com www.gstatic.com; style-src 'self' https: 'unsafe-inline'; frame-src www.google.com;
Run Code Online (Sandbox Code Playgroud)
但是,我想摆脱unsafe-inline该style-src部分.在文档中,写道:
我们建议使用CSP3中记录的基于随机数的方法.确保将你的随机数包含在reCAPTCHA api.js脚本标记中,我们将处理其余部分.
但是我不能让它工作......这就是我尝试过的:
HTML
<script src='//www.google.com/recaptcha/api.js' nonce="{NONCE}" async defer></script>
Run Code Online (Sandbox Code Playgroud)
HTTP标头
Content-Security-Policy: default-src 'self'; script-src 'self' https: 'nonce-{NONCE}'; style-src 'self' 'nonce-{NONCE}'; child-src www.google.com;
Run Code Online (Sandbox Code Playgroud)
这是我在Chrome 53上遇到的错误:
拒绝应用内联样式,因为它违反了以下内容安全策略指令:"style-src'self'https:'nonce- {NONCE}'".可以使用'unsafe-inline'关键字,散列('sha256-MammJ3J + TGIHdHxYsGLjD6DzRU0ZmxXKZ2DvTePAF0o =')或nonce('nonce -...')来启用内联执行.
我错过了什么?
我只是在玩反应查询
带打字稿
我的意思是我做了我的第一次尝试
这是正确的方法吗?
const useCreateTodo = () => {
const queryClient = useQueryClient();
return useMutation(
(todo: TodoDto) => axios.post(`${URL}/todos`, todo).then((res) => res.data),
{
onMutate: async (newTodo: TodoDto) => {
// Cancel any outgoing refetches (so they don't overwrite our optimistic update)
await queryClient.cancelQueries("todos");
// Snapshot the previous value
const previousTodos = queryClient.getQueryData("todos");
// Optimistically update to the new value
queryClient.setQueryData<TodoDto[] | undefined>("todos", (old) =>
old ? [...old, newTodo] : old
);
// Return a context object with the snapshotted …Run Code Online (Sandbox Code Playgroud) 我希望在golang模板中使用string.ToUpper如下大写字符串:
{{ .Name | strings.ToUpper }}
Run Code Online (Sandbox Code Playgroud)
但这不起作用,因为strings它不是我数据的属性.
我无法导入strings包,因为警告我它没有被使用.
在 Python 中,以下代码是有效的:
class A:
def __init__(me):
me.foo = 17
def print_foo(myself):
print(myself.foo)
def set_foo(i, v):
i.foo = v
Run Code Online (Sandbox Code Playgroud)
您可能已经注意到,参数在方法中self命名,在方法中命名,在方法中命名。me__init__myselfprint_fooiset_foo
是否存在将self参数命名为其他名称self有用的情况?如果不是,为什么 Python 允许这样做,因为这肯定是一种编写难以阅读和维护的代码的方式,而且也是混乱的根源?
django ×2
go ×2
python ×2
django-orm ×1
django-urls ×1
iconv ×1
javascript ×1
jquery ×1
mysql ×1
react-query ×1
reactjs ×1
recaptcha ×1
self ×1
shell ×1
string ×1
templates ×1
uppercase ×1
web ×1
window.open ×1