答:
lis = [1, 3, 4, 533, 2333, 8]
def whateveryoucallit(lis):
copylis = lis[:]
copylis.sort(reverse=True)
dic = { v:i+1 for i,v in enumerate(copylis) }
return [ {v:dic[v]} for i,v in enumerate(lis) ]
result = whateveryoucallit(lis)
print(result)
結(jié)果:
[{1: 6}, {3: 5}, {4: 4}, {533: 2}, {2333: 1}, {8: 3}]
用例子補(bǔ)充一下樓上的答案
lis = [1, 3, 4, 533, 2333, 8]
for i, val in enumerate(lis):
print '{}-{}'.format(i, val)
結(jié)果:
0-1
1-3
2-4
3-533
4-2333
5-81.這種不需要用遞歸,用do-while就行
2.答案是合法的,但是你的理解是錯(cuò)誤的
因?yàn)楫?dāng)不合法的時(shí)候,return 保留執(zhí)行(沒(méi)有立即執(zhí)行),當(dāng)合法的時(shí)候,立即執(zhí)行 return ,函數(shù)在return后立即終止,不會(huì)再去執(zhí)行之前未執(zhí)行的 return …
return只會(huì)終止當(dāng)前調(diào)用,不會(huì)終止父調(diào)用,所以return會(huì)一直執(zhí)行
1.你點(diǎn)擊時(shí)跳轉(zhuǎn)時(shí)傳入的參數(shù)是否有問(wèn)題?
2.建議你可以把這部分代碼貼出來(lái),這樣大家也能更好幫你定位問(wèn)題所在!
chrome://version/
個(gè)人資料路徑
Extensions,里面就是你的插件列表了list=['1':'str','2':'str','3':'str'];js沒(méi)有這種格式list = {'1':'str','2':'str','3':'str'} 對(duì)象list = [{'1':'str'},{'2':'str'},{'3':'str'}] 數(shù)組
var json = {};
list.forEach(v=>{
json[v.id] = v.val
})
console.log(json)//{1:'str',2:str,3:'str'}用session
在你用戶沒(méi)有訪問(wèn)權(quán)限,然后重定向之前,這個(gè)時(shí)候你將當(dāng)前路徑存入session
在你登錄之后再取出session里面的路徑,重定向到該路徑即可
跟閉包沒(méi)關(guān)系啊,你下面的那個(gè)返回的是一個(gè)函數(shù),上面的返回的n是一個(gè)值,肯定不行了。
在生成的框架中,打開.webppackrc文件,在其中添加如下配置:
"publicPath":"/", //參數(shù)填寫CDN地址即可
Run npm install --save intl.
Run npm install --save classlist.js.
然后找到src里面的polyfills.ts文件,將注釋打開
然后找到src里面的polyfills.ts文件,將注釋打開
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
*/
/***************************************************************************************************
* BROWSER POLYFILLS
*/
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
import 'classlist.js'; // Run `npm install --save classlist.js`.
/** Evergreen browsers require these. **/
import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/**
* Required to support Web Animations `@angular/animation`.
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
**/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
/***************************************************************************************************
* Zone JS is required by Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/
/**
* Date, currency, decimal and percent pipes.
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
*/
import 'intl'; // Run `npm install --save intl`.
/**
* Need to import at least one locale-data with intl.
*/
import 'intl/locale-data/jsonp/en';尷尬,還是溜了
后端做微信授權(quán)跳轉(zhuǎn)時(shí),使用的協(xié)議與訪問(wèn)的協(xié)議不一致導(dǎo)致的。
請(qǐng)求頭里面加個(gè) “referer”:“當(dāng)前頁(yè)面的URL”
明顯的區(qū)別:靜態(tài)屬性被多個(gè)實(shí)例共享,繼承(成員變量)是每個(gè)實(shí)例獨(dú)立的。
例如用$tao->president = "A"不會(huì)改變$jun->president。
有一定的區(qū)別,如果沒(méi)有特殊需求,也沒(méi)有用到new String("123") 的需求。
String str1="ABC"; 和String str2 = new String("ABC");
String str1="ABC" 可能創(chuàng)建一個(gè)對(duì)象或者不創(chuàng)建對(duì)象,如果"ABC"這個(gè)字符串在java String池里不存在,會(huì)在java String池創(chuàng)建這個(gè)一個(gè)String對(duì)象("ABC").如果已經(jīng)存在,str1直接reference to 這個(gè)String池里的對(duì)象。
String str2 = new String("ABC") 至少創(chuàng)建一個(gè)對(duì)象,也可能兩個(gè)。因?yàn)橛玫絥ew 關(guān)鍵字,會(huì)在heap創(chuàng)建一個(gè) str2 的String 對(duì)象,它的value 是 "ABC".同時(shí),如果"ABC"這個(gè)字符串在java String池里不存在,會(huì)在java String池創(chuàng)建這個(gè)一個(gè)String對(duì)象("ABC").
1.定義一個(gè)數(shù)組arr
2.下拉組件的下拉event
3.event觸發(fā)的時(shí)候,向獲取商品列表的api發(fā)請(qǐng)求(一般這種需求的api都做好分頁(yè))
page是0的時(shí)候,把獲取的數(shù)據(jù)push進(jìn)arr
page不是0的時(shí)候,把獲取的數(shù)據(jù)concat到arr上
就醬
VueRouter跳轉(zhuǎn)的時(shí)候 ,是可以傳遞參數(shù)的,注意需要使用named router,如:
router.push({ name: 'user', params: { userId: 123 }})
另外,就你描述的場(chǎng)景,個(gè)人覺(jué)得沒(méi)必要定義為兩個(gè)Vue組件,組件粒度太細(xì)了,開發(fā)起來(lái)反而麻煩。
不是輸入模式下
:set highlight 設(shè)置語(yǔ)法高亮的.試試json能不能高亮
react不用setState是不會(huì)觸發(fā)改變的
class Content extends React.Component {
constructor(props) {
super(props);
this.state={
majors:[{"name":"****","state":0},{"name":"****","state":0},{"name":"****","state":0}]
}
}
navchange(ind,event){
this.state.majors[ind].state = 1;
this.setState({
majors:this.state.majors
});
}
render(){
return (
<div>
<div className="top">
<div className="search">
<input type="text" placeHolder="請(qǐng)輸入搜索內(nèi)容" />
<span><img src="img/search.png" alt="" /></span>
</div>
<div className="majors">{
this.state.majors.map(function(item,index){
return<span className="major" key={index} onClick={this.navchange.bind(this,index)}><span className={item.state == "0" ? 'in':''} >{item.name}</span></span>
}.bind(this))
}
</div>
</div>
</div>
)
}
}package com.elyong.noway;
/**
* Created by ely ong on 2017/11/27.
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class SimpleGui3C implements ActionListener{
JFrame frame;
public static void main(String[] args){
SimpleGui3C gui=new SimpleGui3C();
gui.go();
}
public void go(){
//你的這里沒(méi)有賦值
frame=new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JButton button=new JButton("Change colors");
button.addActionListener(this);
MyDrawPanel drawPanel=new MyDrawPanel();
frame.getContentPane().add(BorderLayout.SOUTH,button);
frame.getContentPane().add(BorderLayout.CENTER,drawPanel);
frame.setSize(300,300);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent event){
frame.repaint();
}
}
class MyDrawPanel extends JPanel{
public void paintComponent(Graphics g){
Graphics2D g2d=(Graphics2D) g;
int red=(int)(Math.random()*255);
int green=(int)(Math.random()*255);
int blue=(int)(Math.random()*255);
Color startColor=new Color(red,green,blue);
red=(int)(Math.random()*255);
green=(int)(Math.random()*255);
blue=(int)(Math.random()*255);
Color endColor=new Color(red,green,blue);
GradientPaint gradient=new GradientPaint(70,70,startColor,150,150,endColor);
g2d.setPaint(gradient);
g2d.fillOval(70,70,100,100);
}
}北大青鳥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)師。