將 find_str() 里的 if (*(*strings)++ == value) 展開成兩段,如下
1 int find_str(char **strings, char value)
2 {
3 while (*strings != NULL) {
4 while (**strings != '\0') {
5 int match = **strings == value;
6 (*strings)++;
7 if (match) {
8 return TRUE;
9 }
10 }
11 strings++;
12 }
13 return FALSE;
14 }
這里只有兩處會(huì)修改變量值
你可以這樣理解第二處的修改
strings[i] = strings[i] + 1;
而 strings[i] 是一個(gè)字符串指針,因此每執(zhí)行一次將導(dǎo)致該字符串指針往后移,
直到找到目標(biāo)字符,或字符串結(jié)尾。
舉一反三,計(jì)算下面代碼運(yùn)行完之后,各個(gè)變量的值
char *s0 = "123";
char *s1 = "abc";
char *s2 = NULL;
char *strings[] = {s0, s1, s2};
(*strings)++;
答案是只有 strings 的第一個(gè)元素被改了,原來(lái)是 s0,變成 s0 + 1。
原因:reader.onload = function() {} 并不是阻塞的,在讀取完成之前就繼續(xù)往下走了,到this.imgLists.push(newImg);這一行的時(shí)候newImg還是空的。你setTimeout其實(shí)是在賭讀取完成需要多久,如果秒讀就能工作,否則不能,所以你實(shí)驗(yàn)幾次結(jié)果不同。
解決:
把下面一串都放到異步成功的回調(diào)里面去
addImg(e) {
let newImg = {};
let file = e.target;
let reader = new FileReader();
reader.readAsDataURL(file.files[0]);
reader.onload = () => {
newImg.data = reader.result;
if (this.imgLists.length <= 5) {
this.imgLists.push(newImg);
}
else {
this.$message({
message: '最多僅支持上傳5張圖片',
type: 'warning',
center: true,
});
}
}
}
我不太理解你的問(wèn)題,before 一次 after 一次不是正好
12
34
56
如果你想要每次 +2,應(yīng)該是:
p::before {
counter-increment:pl 2;
content: counter(pl);
}
p::after {
content: counter(pl);
}
CSS 里重復(fù)多次的結(jié)果,會(huì)把所有樣式合并到一起,所以重復(fù)兩次和只寫一次效果是一樣的。
你在用malloc申請(qǐng)數(shù)組空間的時(shí)候a,b還沒(méi)有賦值,他們倆的值是未定義的。你申請(qǐng)的數(shù)組的長(zhǎng)度也不知道多長(zhǎng),所以在給數(shù)組賦值時(shí)就會(huì)越界。
解決辦法:
把給a,b賦值的兩個(gè)scanf語(yǔ)句放到Malloc之前。
Object.prototype.__proto__,事實(shí)證明可以使用
function ClassA(name) {
this.name = name
}
ClassA.prototype.sayName = function () {
alert(this.name)
}
function ClassB(name, age) {
ClassA.call(this, name)
this.age = age
}
ClassB.prototype.__proto__ = ClassA.prototype
ClassB.prototype.sayAge = function () {
alert(this.age)
}
let instance = new ClassB('小明', 11)
instance.sayName(); //小明
instance.sayAge(); //11可以通過(guò)反射獲取注解
這邊有示例http://blog.csdn.net/bao19901...
估計(jì)是static惹的禍。它會(huì)一直保存每一次測(cè)試用例的結(jié)果,并不會(huì)重新開始計(jì)數(shù)。所以你直接對(duì)那個(gè)失敗的測(cè)試用例可以過(guò),而對(duì)多個(gè)測(cè)試用例(也就是commit)過(guò)不了
<?php
class Tree{
static public function SortTree($data, $pid = 0, $level=0, $icon = array(' ├─', ' └─',' │'))
{
$str="";$arr=[];
if(empty($data)) return array();
foreach ($data as $k=>$v) {
if ($v['pid'] == $pid) {
$v['level']= $level+1;
if($v['level']>2){
$str=str_repeat($icon[2], $v['level']-2);
}
if($v['pid']== 0){
$v['html']='';
}else{
$v['html']= $str . $icon[0];
}
$arr[] =$v;
$arr = array_merge($arr, self::SortTree($data, $v['cid'], $level + 1));
}
}
return $arr;
}
static public function getTree($data,$icon = array(' ├─', ' └─',' │')){
if(!is_array($data) || empty($data)) return array();
$arr = self::SortTree($data, $pid = 0, $level=0, $icon = array(' ├─', ' └─',' │'));
foreach ($arr as $k => $v) {
$str = "";
if ($v['level'] > 2) {
for ($i = 1; $i < $v['level'] - 1; $i++) {
$str .= " │";
}
}
if($v['level']!=1){
if (isset($arr[$k + 1]) && $arr[$k + 1]['level'] >= $arr[$k]['level']) {
$arr[$k]['html'] =$str . $icon[0];
} else {
$arr[$k]['html'] = $str . $icon[1];
}
}else{
$arr[$k]['html'] = $v['html'];
}
}
return $arr;
}
}
$data=array(
['cid' => 1, 'pid' => 0,'name'=>'a1'],
['cid' => 2, 'pid' => 1,'name'=>'a2'],
['cid' => 3, 'pid' => 2,'name'=>'a3'],
['cid' => 4, 'pid' => 2,'name'=>'a4'],
['cid' => 5, 'pid' => 0,'name'=>'a5'],
['cid' => 6, 'pid' => 5,'name'=>'a6'],
['cid' => 7, 'pid' => 6,'name'=>'a7'],
['cid' => 8, 'pid' => 7,'name'=>'a8'],
['cid' => 9, 'pid' => 7,'name'=>'a9'],
['cid' => 10, 'pid' => 8,'name'=>'a10'],
['cid' => 11, 'pid' => 10,'name'=>'11'],
['cid' => 12, 'pid' => 11,'name'=>'12'],
['cid' => 13, 'pid' => 12,'name'=>'13'],
['cid' => 14, 'pid' => 13,'name'=>'14'],
['cid' => 15, 'pid' => 14,'name'=>'15'],
['cid' => 16, 'pid' => 15,'name'=>'16'],
);
$tree=new Tree();
$a=$tree->getTree($data);
foreach ($a as $k=>$v){
echo $v['html'].$v['name'].' ---level:'.$v['level'].'<br>';
}
最后最近勉強(qiáng)解決了,如果哪里有問(wèn)題,歡迎大神幫我指導(dǎo)修正。
最終結(jié)果:
a1 ---level:1
?├─a2 ---level:2
?│?├─a3 ---level:3
?│?└─a4 ---level:3
a5 ---level:1
?├─a6 ---level:2
?│?├─a7 ---level:3
?│?│?├─a8 ---level:4
?│?│?│?├─a10 ---level:5
?│?│?│?│?├─11 ---level:6
?│?│?│?│?│?├─12 ---level:7
?│?│?│?│?│?│?├─13 ---level:8
?│?│?│?│?│?│?│?├─14 ---level:9
?│?│?│?│?│?│?│?│?├─15 ---level:10
?│?│?│?│?│?│?│?│?│?└─16 ---level:11
?│?│?└─a9 ---level:4
祝大家 五福臨門,新年快樂(lè)!
Linux的管道實(shí)現(xiàn)是個(gè)環(huán)形緩沖區(qū):
/**
* struct pipe_buffer - a linux kernel pipe buffer
* @page: the page containing the data for the pipe buffer
* @offset: offset of data inside the @page
* @len: length of data inside the @page
* @ops: operations associated with this buffer. See @pipe_buf_operations.
* @flags: pipe buffer flags. See above.
* @private: private data owned by the ops.
**/
struct pipe_buffer {
struct page *page;
unsigned int offset, len;
const struct pipe_buf_operations *ops;
unsigned int flags;
unsigned long private;
};
/**
* struct pipe_inode_info - a linux kernel pipe
* @mutex: mutex protecting the whole thing
* @wait: reader/writer wait point in case of empty/full pipe
* @nrbufs: the number of non-empty pipe buffers in this pipe
* @buffers: total number of buffers (should be a power of 2)
* @curbuf: the current pipe buffer entry
* @tmp_page: cached released page
* @readers: number of current readers of this pipe
* @writers: number of current writers of this pipe
* @files: number of struct file referring this pipe (protected by ->i_lock)
* @waiting_writers: number of writers blocked waiting for room
* @r_counter: reader counter
* @w_counter: writer counter
* @fasync_readers: reader side fasync
* @fasync_writers: writer side fasync
* @bufs: the circular array of pipe buffers
* @user: the user who created this pipe
**/
struct pipe_inode_info {
struct mutex mutex;
wait_queue_head_t wait;
unsigned int nrbufs, curbuf, buffers;
unsigned int readers;
unsigned int writers;
unsigned int files;
unsigned int waiting_writers;
unsigned int r_counter;
unsigned int w_counter;
struct page *tmp_page;
struct fasync_struct *fasync_readers;
struct fasync_struct *fasync_writers;
struct pipe_buffer *bufs;
struct user_struct *user;
};
curbuf是當(dāng)前緩存區(qū)的下標(biāo),每個(gè)緩沖區(qū)里有offset和len記錄數(shù)據(jù)寫到的位置,讀寫的時(shí)候是要修改這些信息的。
如果兩個(gè)進(jìn)程同時(shí)進(jìn)行讀或者同時(shí)進(jìn)行寫,必要會(huì)導(dǎo)致數(shù)據(jù)沖突,所以內(nèi)核會(huì)對(duì)管道上鎖(pipe_inode_info里的mutex),所以是半雙工的。
比較簡(jiǎn)單的實(shí)現(xiàn)可以看xv6的實(shí)現(xiàn):
struct pipe {
struct spinlock lock;
char data[PIPESIZE];
uint nread; // number of bytes read
uint nwrite; // number of bytes written
int readopen; // read fd is still open
int writeopen; // write fd is still open
};
直接一塊連續(xù)的內(nèi)存data,用兩個(gè)數(shù)字nread、nwrite記錄讀寫數(shù),通過(guò)PIPESIZE取模得到在data上的讀寫位置,用自旋鎖保護(hù)。如果沒(méi)有鎖,兩個(gè)進(jìn)程就能同時(shí)寫數(shù)據(jù)到data和修改nwrite,數(shù)據(jù)也就沖突了,同時(shí)讀也同理。
結(jié)論: test()是A的,$this也是A的,調(diào)用自己私有的foo()很正常嘛。
延伸:為什么A中的foo()改為public結(jié)果不一樣了呢?
因?yàn)锽是繼承A的,B把foo()繼承又重寫了,所以A中的foo()不能再用$this訪問(wèn)了,只能用parent::foo()
不能繼承是關(guān)鍵。
#先執(zhí)行@Decorator2裝飾的裝飾函數(shù)plugger2()
@Decorator2
def plugger2():
...
#等同于下面:
Decorator2(plugger2)
#即按照下面的流程來(lái)執(zhí)行,下面也是這個(gè)函數(shù)的整體流程,即先執(zhí)行plugger2(),最后再打印"plugger2內(nèi)調(diào)"
#再好好分析一下,下面這個(gè)流程就是這個(gè)函數(shù)執(zhí)行的流程,這里要弄明白。
plugger2()
print("Plugger2 內(nèi)調(diào) here!") #P4
這里就是你疑惑的關(guān)鍵點(diǎn)之一,實(shí)際上你明白了上面函數(shù)的執(zhí)行流程,你也就明白了為什么"plugger2內(nèi)調(diào)會(huì)最后打印了"
無(wú)論如何,print("Plugger2 內(nèi)調(diào) here!")會(huì)在plugger2()函數(shù)執(zhí)行完成之后再執(zhí)行,所以它一定會(huì)是最后執(zhí)行的語(yǔ)句
然后我們看plugger()函數(shù)是怎么執(zhí)行的:
9 def plugger2():
10 print ("Plugger2 外調(diào) here!") #P1
11 @Decorator3
12 def plugger3():
13 print ("Plugger3 外調(diào) here!")
#############################################
# 首先執(zhí)行print ("Plugger2 外調(diào) here!"),這也是整個(gè)函數(shù)最先執(zhí)行的一個(gè)print語(yǔ)句
# 然后plugger2里面又嵌套了一個(gè)裝飾器,按照上面的分析方式再來(lái)一次
Decorator3(plugger3)
||
||
\/
plugger3() # P2
print ("Plugger3 內(nèi)調(diào) here!") #P3
到了這里所有print順序都已經(jīng)理清楚了。按照我標(biāo)注的P1--P4的順序打印的。
第9行沒(méi)有結(jié)束的原因是:
before_func()沒(méi)有返回值,默認(rèn)返回None.
所以if before_result != None是不成立的,會(huì)繼續(xù)往下執(zhí)行。
native 是因?yàn)槟愕揭欢ǖ夭胶髸?huì)有自己封裝本地組件的需求。
所以要么請(qǐng)別人寫、等別人寫,要么就自己學(xué)著寫。所以成本上最好還是要有兩方面準(zhǔn)備。
單看這段規(guī)則沒(méi)任何問(wèn)題的。
因該是你程序有上傳漏洞,比如圖片上傳,用戶上傳了uurs.php的非法文件,通過(guò)php重寫了htaccess文件。。
你這個(gè)無(wú)非就是枚舉法,至于所謂加法運(yùn)算,不明白,既然是一對(duì)多,兩個(gè) for 循環(huán)?
找到答案了
重新安裝
1、卸載 pip uninstall Pillow-2.3.0
2、安裝 pip install Pillow(沒(méi)指定版本,默認(rèn)最新的 Pillow-4.3.0)
使用setTimeout異步異步獲取一下?或者如果使用的是vue的話,可以使用Vue.nextTick
conf 下面確實(shí)沒(méi)有cert這個(gè)路徑啊,從你的圖上看來(lái)的話
從你上面的信息來(lái)看,那就是 git 操作超時(shí)問(wèn)題,也就是網(wǎng)絡(luò)問(wèn)題.
1) 你先在服務(wù)器上嘗試自動(dòng), git clone 下相應(yīng)項(xiàng)目. 檢查并排除網(wǎng)絡(luò)問(wèn)題.
2) 如果沒(méi)有使用過(guò)的 fastlane 的話,推薦.
const fs = require('fs');
const readable = getReadableStreamSomehow();
const writable = fs.createWriteStream('file.txt');
// All the data from readable goes into 'file.txt'
readable.pipe(writable);
你nm命令看到的那些符號(hào)的“U”表示未定義的,你可以看到它們前面沒(méi)有內(nèi)存地址信息,這些符號(hào)是定義在你引入的mxml庫(kù)中的。
你是在生成可執(zhí)行程序main的失敗報(bào)錯(cuò)的吧,如果是在編譯的時(shí)候再加上-lmxml選項(xiàng),并使用-L選項(xiàng)指定mxml庫(kù)所在的目錄。
運(yùn)行時(shí)可能會(huì)遇到提示找不到libmxml.so**庫(kù)的錯(cuò)誤提示,可以把libmxml.so**庫(kù)發(fā)布到/usr/lib64目錄下,或者把libmxml.so**所在目錄配置到/etc/ld.so.conf中,然后執(zhí)行l(wèi)dconfig即可。
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國(guó)IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國(guó)家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國(guó)一站式人才培養(yǎng)平臺(tái)、一站式人才輸送平臺(tái)。2014年4月3日在美國(guó)成功上市,融資1
北大課工場(chǎng)是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國(guó)家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國(guó)制造2025”,實(shí)現(xiàn)中華民族偉大復(fù)興的升級(jí)產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國(guó)職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項(xiàng)目經(jīng)理從事移動(dòng)互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項(xiàng)目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺(tái)面向?qū)ο箝_發(fā)經(jīng)驗(yàn),技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點(diǎn)難點(diǎn)突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫(kù),具有快速界面開發(fā)的能力,對(duì)瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁(yè)制作和網(wǎng)頁(yè)游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗(yàn)。曾經(jīng)歷任德國(guó)Software AG 技術(shù)顧問(wèn),美國(guó)Dachieve 系統(tǒng)架構(gòu)師,美國(guó)AngelEngineers Inc. 系統(tǒng)架構(gòu)師。