$ ls *mp3 | xargs mplayer
Playing Lemon.
File not found: 'Lemon'
Playing Tree.mp3.
File not found: 'Tree.mp3'
Exiting... (End of file)
Run Code Online (Sandbox Code Playgroud)
我的命令失败,因为文件"Lemon Tree.mp3"包含空格,因此xargs认为它是两个文件.我可以使find + xargs使用这样的文件名吗?
如果我不知道这个词有多长,我就不会写char m[6];
,
这个词的长度可能是十到二十个.如何使用scanf
键盘输入?
#include <stdio.h>
int main(void)
{
char m[6];
printf("please input a string with length=5\n");
scanf("%s",&m);
printf("this is the string: %s\n", m);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
请输入一个lenght = 5
的字符串
你好
这是字符串:hello
debian@debian:~$ echo $PYTHONPATH
/home/qiime/lib/:
debian@debian:~$ python
Python 2.7.3 (default, Jan 2 2013, 16:53:07)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python2.7/dist-packages/feedparser-5.1.3-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/stripogram-1.5-py2.7.egg', '/home/qiime/lib',
'/home/debian', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-
dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7']
Run Code Online (Sandbox Code Playgroud)
如何在bash中获得所有pythonpath输出?
为什么 PYTHONPATH
不能得到所有这些?
我的Gmail中有2465封电子邮件,为什么程序在下载完所有电子邮件后无法停止?所有code1和code2都在命令行模式下运行.
代码1:
<?php
$mailbox = array(
'mailbox' => '{imap.gmail.com:993/imap/ssl}INBOX',
'username' => 'xxxx@gmail.com',
'password' => 'yyyy'
);
$stream = imap_open($mailbox['mailbox'], $mailbox['username'], $mailbox['password'])
or die('Cannot connect to mailbox: ' . imap_last_error());
$emails = imap_search($stream,"ALL");
$nums=imap_num_msg($stream);
echo $nums;
foreach($emails as $email_id) {
$mime = imap_fetchbody($stream, $email_id, "");
file_put_contents("/tmp/" . "email_{$email_id}.eml", $mime);
}
imap_close($stream);
echo "over";
?>
Run Code Online (Sandbox Code Playgroud)
对于code1:1
.可以下载所有电子邮件.
在控制台2.输出2465
3.no over
在控制台上输出.
4.程序无法停止,它似乎永远运行.
码2:
<?php
$mailbox = array(
'mailbox' => '{imap.gmail.com:993/imap/ssl}INBOX',
'username' => 'xxxx@gmail.com',
'password' => 'yyyy'
);
$stream = imap_open($mailbox['mailbox'], $mailbox['username'], $mailbox['password']) …
Run Code Online (Sandbox Code Playgroud) "/home/test.mp4"
我的本地机器中有一个文件,
我想将其上传到/var/www/ok.mp4
(上传时更改的名称).所有源文件和目标文件都在本地计算机中.
如何修复我的部分代码,添加内容或更改某些内容?
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_exec($ch);
?>
Run Code Online (Sandbox Code Playgroud)
想想Ram Sharma,代码改变如下:
<?php
$request = curl_init('http://127.0.0.1/');
curl_setopt($request, CURLOPT_POST, true);
curl_setopt(
$request,
CURLOPT_POSTFIELDS,
array(
'file' => '@' . realpath('/home/test.mp4')
));
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
echo curl_exec($request);
// close the session
curl_close($request);
?>
Run Code Online (Sandbox Code Playgroud)
出现错误消息:
有用!
这是此服务器的默认网页.
Web服务器软件正在运行,但尚未添加任何内容.
我用ftp_put测试,code1工作正常.
代码1:
<?php
set_time_limit(0);
$host = 'xxxx';
$usr = 'yyyy';
$pwd = 'zzzz';
$src = 'd:/upload.sql';
$ftp_path = '/public_html/'; …
Run Code Online (Sandbox Code Playgroud) 我的计算机上有两个R目录:
一个是/home/R-2.15.2
,另一个是/home/R-2.15.1
,
当我输入时R
,我可以启动R,现在我想知道哪个R正在运行:2.15.1或2.15.2?
这是我的代码:
<?php
$url="http://www.sina.com.cn";
$handle = @fopen($url, "r");
$len=get_headers($url,true);
print_r($len);
echo $len['Content-Length']."\n";
if ($handle) {
while (($buffer = fgets($handle,1024)) !== false) {
echo ftell($handle)."\n";
fseek($handle,200000,SEEK_CUR);
echo ftell($handle)."\n";
}
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
?>
Run Code Online (Sandbox Code Playgroud)
结果如下:
Array
(
[0] => HTTP/1.1 200 OK
[Content-Type] => text/html
[Vary] => Accept-Encoding
[X-Powered-By] => shci_v1.03
[Server] => nginx
[Date] => Thu, 24 Dec 2015 04:03:39 GMT
[Last-Modified] => Thu, 24 Dec 2015 04:01:28 GMT
[Expires] => Thu, 24 Dec …
Run Code Online (Sandbox Code Playgroud) >>> class Foo:
... 'it is a example'
... print 'i am here'
...
i am here
>>> Foo.__name__
'Foo'
>>> Foo().__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: Foo instance has no attribute '__name__'
>>> Foo.__doc__
'it is a example'
>>> Foo().__doc__
'it is a example'
>>> Foo.__dict__
{'__module__': '__main__', '__doc__': 'it is a example'}
>>> Foo().__dict__
{}
>>> Foo.__module__
'__main__'
>>> Foo().__module__
'__main__'
>>> myname=Foo()
>>> myname.__name__
Traceback (most recent call last):
File …
Run Code Online (Sandbox Code Playgroud) <input type="button" value="mybutton1" onclick="dosomething()">test
Run Code Online (Sandbox Code Playgroud)
点击按钮时会引发dosomething函数,如何将按钮的值传递给mybutton1
dosomething函数作为参数?
这是我的主要分解程序,我添加了一个回调函数pool.apply_async(findK, args=(N,begin,end))
,prime factorization is over
当分解结束时消息提示,它工作正常.
import math
import multiprocessing
def findK(N,begin,end):
for k in range(begin,end):
if N% k == 0:
print(N,"=" ,k ,"*", N/k)
return True
return False
def prompt(result):
if result:
print("prime factorization is over")
def mainFun(N,process_num):
pool = multiprocessing.Pool(process_num)
for i in range(process_num):
if i ==0 :
begin =2
else:
begin = int(math.sqrt(N)/process_num*i)+1
end = int(math.sqrt(N)/process_num*(i+1))
pool.apply_async(findK, args=(N,begin,end) , callback = prompt)
pool.close()
pool.join()
if __name__ == "__main__":
N = 684568031001583853
process_num = 16 …
Run Code Online (Sandbox Code Playgroud)