小编it_*_*ure的帖子

eval SyntaxError:python中的语法无效

我想分配:

x0='123'    
x1='123'    
x2='123'    
x3='123'    
x4='123'    
x5='123'    
x6='123'    
x7='123'    
x8='123'    
x9='123'    
Run Code Online (Sandbox Code Playgroud)

我编写代码来表示我可以123在输入时获取字符串的输出x1x8.

for i in range(0,10):
    eval("x"+str(i)+"='123'")

Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "<string>", line 1
  x0='123'
  ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我怎么能这样做?

python

11
推荐指数
2
解决办法
2万
查看次数

其余的at命令可以简化吗?

rest(){
    echo "have a rest in "$1 " minutes"
    at -f /home/rest.sh now+$1 minutes
}
Run Code Online (Sandbox Code Playgroud)

编辑rest.sh脚本.

vim /home/rest.sh
xscreensaver-command --lock
Run Code Online (Sandbox Code Playgroud)

测试它.

rest 60
have a rest in 60  minutes
warning: commands will be executed using /bin/sh
job 7 at Thu Feb  9 11:15:00 2017
Run Code Online (Sandbox Code Playgroud)

可以at简化静止的命令吗?
删除/home/rest.sh,用管道或其他方式传递参数?

linux bash shell

11
推荐指数
1
解决办法
163
查看次数

如何在wordpress搜索栏中更改搜索操作?

创建一个新帖子并发布它.

标题是my test for search,内容如下:

no host route
Run Code Online (Sandbox Code Playgroud)

检查wordpress数据库中发生了什么.

 select post_title from wp_posts
     where post_content like "%no%"
       and post_content like "%route%"
       and post_content like "%to%"
       and post_content like "%host%";
Run Code Online (Sandbox Code Playgroud)

命名的帖子my test for search不在select的结果中.
键入no route to hostwordpress搜索栏,然后单击"输入".命名的帖子my test for search显示为结果.

在此输入图像描述

我找到了网页的原因to,在左上角,有一个单词Customize包含搜索到的单词to.
如何在wordpress serach栏中更改此类搜索操作?
我想在wordpress saerch bar中进行搜索行为,例如,当您键入时no route to host,等于以下sql命令.

select post_title from wp_posts where post_content like "%no%route%to%host%";
Run Code Online (Sandbox Code Playgroud)

我的wordpress中的所有插件.

CodePen Embedded Pens Shortcode
Crayon Syntax …
Run Code Online (Sandbox Code Playgroud)

mysql wordpress search

11
推荐指数
1
解决办法
254
查看次数

如何编写expect脚本来安装mariadb?

环境:centos7 + mariadb5.5.64。
让我在屏幕上显示安装信息何时运行mysql_secure_installation

# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): …
Run Code Online (Sandbox Code Playgroud)

automation centos expect mariadb tcltk

11
推荐指数
1
解决办法
764
查看次数

如何在php cli中输入中文字符?

中文字符可以在我的LXTerminal上显示和输入.

root@hwy:/home/debian8# ??    \\now to input chinese characters on my LXTerminal,it means  chinese characters can be inputted.
bash: ??: command not found   \\ bash react the  chinese characters on my LXTerminal,it means  chinese characters can be displayed.    
Run Code Online (Sandbox Code Playgroud)

中文字符可以输入并显示在我的python shell上.
在此输入图像描述 现在让我们进入php cli(或说php shell)

在此输入图像描述

在此输入图像描述 点击回车键时汉字消失了.
这意味着可以显示中文字符但不能在php cli模式下输入.
如何在php cli模式下输入汉字?
事实证明,中文字符也不能粘贴到php cli中.
也许某些mbstring属性将在/etc/php5/cli/php.ini中编辑?

感谢bwoebi.继续我研究的三个事实.
1. libreadline和libedit的版本.

root@hwy:/home/debian8# find /  -name   'libreadline*'
/lib/x86_64-linux-gnu/libreadline.so.6.3
/lib/x86_64-linux-gnu/libreadline.so.6


root@hwy:/home/debian8# find /  -name   'libedit*'
/usr/lib/x86_64-linux-gnu/libedit.so.2
/usr/lib/x86_64-linux-gnu/libedit.so.2.0.51
/usr/share/lintian/overrides/libedit2
Run Code Online (Sandbox Code Playgroud)

2.root@hwy:/ home/debian8 #ldd"$(哪个php)"

linux-vdso.so.1 (0x00007ffd35e5c000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007ff98ac68000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 …
Run Code Online (Sandbox Code Playgroud)

php

10
推荐指数
1
解决办法
373
查看次数

如何使用js在网页中提取所有当前视频文件及其地址?

 var imgs=document.images.length;
Run Code Online (Sandbox Code Playgroud)

它可以提取网页上的所有图像.
如何提取所有后缀为flv的flv文件,例如sample.flv在带有js的网页中?不是我本地目录中的所有flv文件而是网页.firefox中
的插件Video DownloadHelper可以获取当前的mp4文件.
在此输入图像描述 为什么我的js代码不能执行相同的任务?

var Links = document.querySelectorAll('a[href$=".mp4"]');
console.log(Links);
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

如何用fires中的插件等js提取当前视频文件Video DownloadHelper

javascript dom web-scraping

10
推荐指数
1
解决办法
5305
查看次数

用于python和debian的Unicode版本9

对于我的debian9中的unicode版本

ls   /usr/share/doc/unicode-data
changelog.Debian.gz  copyright
Run Code Online (Sandbox Code Playgroud)

提取changelog.Debian.gz,一些版本信息如下:

unicode-data (9.0-1) unstable; urgency=medium

  * New upstream release. Closes: #827098.
  * Move to Standards-Version: 3.9.6. No changes required.

 -- Alastair McKinstry <mckinstry@debian.org>  Wed, 22 Jun 2016 14:49:26 +0100

unicode-data (8.0-3) unstable; urgency=medium

  * Fetch new allkeys.txt for Unicode 8. Closes: #809188.
  * Move to S-V: 3.9.6. No changes required.
  * Fix sort error in NameAliases.txt. Closes: #808465.

 -- Alastair McKinstry <mckinstry@debian.org>  Tue, 29 Dec 2015 02:15:32 +0000
Run Code Online (Sandbox Code Playgroud)

我的debian9的unicode版本是9.0-1?

对于python3中的unicode版本

>>> import unicodedata
>>> unicodedata.unidata_version …
Run Code Online (Sandbox Code Playgroud)

python unicode debian version

10
推荐指数
1
解决办法
160
查看次数

使用ajax发出http请求以获取基本授权和cors

我的httpd服务器的配置111.111.111.111(假设).
配置cors和基本身份验证 /etc/httpd/conf/httpd.conf.

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride AuthConfig
    Require all granted
    Header always set Access-Control-Allow-Origin "*"
    Header always set Access-Control-Allow-Methods "POST, GET, PUT, DELETE, OPTIONS"
    Header always set Access-Control-Allow-Credentials "true"
    Header always set Access-Control-Allow-Headers "Authorization,DNT,User-Agent,Keep-Alive,Content-Type,accept,origin,X-Requested-With"
</Directory>
Run Code Online (Sandbox Code Playgroud)

为我的服务器上的基本授权制作更多配置111.111.111.111.

cd /var/www/html && vim .htaccess
AuthName "login"  
AuthType Basic  
AuthUserFile /var/www/html/passwd  
require user username 
Run Code Online (Sandbox Code Playgroud)

为用户名创建密码.

htpasswd -c /var/www/html/passwd username
Run Code Online (Sandbox Code Playgroud)

重新启动httpd:

systemctl restart httpd
Run Code Online (Sandbox Code Playgroud)

/var/www/html/remote.html服务器上111.111.111.111.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta …
Run Code Online (Sandbox Code Playgroud)

javascript apache authentication cors jqxhr

10
推荐指数
1
解决办法
979
查看次数

如何计算分组数据集的中位数?

我的数据集如下:

salary  number
1500-1600   110
1600-1700   180
1700-1800   320
1800-1900   460
1900-2000   850
2000-2100   250
2100-2200   130
2200-2300   70
2300-2400   20
2400-2500   10
Run Code Online (Sandbox Code Playgroud)

如何计算此数据集的中位数?这是我尝试过的:

x <- c(110, 180, 320, 460, 850, 250, 130, 70, 20, 10)
colnames <- "numbers"
rownames <- c("[1500-1600]", "(1600-1700]", "(1700-1800]", "(1800-1900]", 
              "(1900-2000]", "(2000,2100]", "(2100-2200]", "(2200-2300]",
              "(2300-2400]", "(2400-2500]")
y <- matrix(x, nrow=length(x), dimnames=list(rownames, colnames))
data.frame(y, "cumsum"=cumsum(y))

            numbers cumsum
[1500-1600]     110    110
(1600-1700]     180    290
(1700-1800]     320    610
(1800-1900]     460   1070
(1900-2000]     850   1920
(2000,2100]     250   2170
(2100-2200] …
Run Code Online (Sandbox Code Playgroud)

r median

9
推荐指数
1
解决办法
1万
查看次数

如何在r控制台中显示和输入中文(和其他非ASCII)字符?

我的系统:win7 ultimate 64英文版+ r-3.1(64).
这是我的sessionInfo.

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252     
LC_MONETARY=English_United States.1252 LC_NUMERIC=C      
LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
Run Code Online (Sandbox Code Playgroud)

1.无法在r控制台中输入中文字符
当我在r控制台中输入中文字符时,它会变成乱码.

在此输入图像描述 在此输入图像描述

2.无法在r控制台上显示中文字符
当我在r控制台中读取数据时,中文字符变成乱码.
您可以下载数据并进行测试

read.table("r1.csv",sep=",")
Run Code Online (Sandbox Code Playgroud)

下载数据

在此输入图像描述

如果您不知道如何从我的网站获取数据,请查看图表以下载数据.

在此输入图像描述

如何设置我的电脑以在r控制台中正确显示和输入中文字符?我已经更新了中文语言包并启用了它,但问题仍然存在.

r

9
推荐指数
1
解决办法
7881
查看次数