我正在学习制作Todo应用程序.在网站上,我正在学习的是https://coderwall.com/p/4gzjqw/build-a-javascript-todo-app-with-express-jade-and-mongodb
我输入的指令描述,
[app.js]
var main = require('./routes/main');
var todo = require('./routes/todo');
var todoRouter = express.Router();
app.use('/todos', todoRouter);
app.get('/', main.index);
todoRouter.get('/',todo.all);
todoRouter.post('/create', todo.create);
todoRouter.post('/destroy/:id', todo.destroy);
todoRouter.post('/edit/:id', todo.edit);
[/routes/todo.js]
module.exports ={
all: function(req, res){
res.send('All todos');
},
viewOne: function(req, res){
console.log('Viewing '+req.params.id);
},
create: function(req, res){
console.log('Todo created');
},
destroy: function(req, res){
console.log('Todo deleted');
},
edit: function(req, res){
console.log('Todo '+req.params.id+' updated');
}
};
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息
错误:Route.get()需要回调函数但得到[对象未定义]
我在这里错过了什么吗?
我想在Searbon lmplot上添加标题.
ax = plt.axes()
sns.lmplot(x, y, data=df, hue="hue", ax=ax)
ax.set_title("Graph (a)")
plt.show()
Run Code Online (Sandbox Code Playgroud)
但我注意到lmplot
没有ax
参数.如何在我的lmplot上添加标题?
我正在构建简单的网络应用程序,如果用户按下按钮,它将发出声音(服务器端的 mp3 文件)。
//html file
<script>
function playSound () {
document.getElementById('play').play();
}
</script>
<body>
<audio id='play', src='http://127.0.0.1:1337/', type='audio/mpeg'
<button onclick='playSound()' class='btn btn-danger btn-circle btn-lg'>
<i class='fa fa-5x fa-fire'>
</body>
//app.js
app.get('/music.mp3', function(req, res){
ms.pipe(req, res, "/music.mp3");
});
Run Code Online (Sandbox Code Playgroud)
如果我在audio
属性中插入在线源,它会起作用,但它不会为我的本地服务器文件提供服务。我怎样才能解决这个问题?
提前致谢!
我正在实现从 python 中的两个链表中添加两个数字的算法。(来自破解编码面试2-5)
例如,
first: 7 -> 1 -> 6 617
second: 5 -> 9 -> 2 +295
-----
912
output: 2 -> 1 -> 9 ( which indicates 912 )
Run Code Online (Sandbox Code Playgroud)
这是我的代码
class Node:
def __init__(self, val=None):
self.data = val
self.Next = None
class LinkedList:
def __init__(self):
self.head = None
self.size = 0
def __repr__(self):
temp = self.head
alist = []
while temp:
alist.append(temp.data)
temp = temp.Next
return str(alist)
def add(self, val):
cur = self.head
prev = None
if cur …
Run Code Online (Sandbox Code Playgroud) 我是一个Java新手,通过文档学习框架。我想知道如何区分正在使用哪个框架?是在吗pom.xml
?或者spring.xml
?
如果是,使用什么标签?
谢谢!
我将 Material-UI 与 React 和 TypeScript 结合使用。
<TextField
id='user-id'
label='user id'
type='number'
required
helperText='Required'
inputProps={{ maxLength : 12 }}
onChange={(e) => setUserid(Number(e.target.value))}
variant='filled' />
Run Code Online (Sandbox Code Playgroud)
如果我将type
属性与 一起使用inputProps
,它不会限制最大长度。我没有看到任何错误消息。我不明白我哪里做错了。
我正在使用pandas,Python操纵DataFrame.我的数据是10000(行)X 20(列),我正在想象它,就像这样.
df.hist(figsize=(150,150))
Run Code Online (Sandbox Code Playgroud)
但是,如果我使figsize更大,每个子图的标题(每列的名称)变得非常小或图形相互重叠,这使得无法区分.
有没有聪明的方法来解决它?
谢谢!
我想在python2.x中构建简单的分数计算器
from fractions import Fraction
class Thefraction:
def __init__(self,a,b):
self.a = a
self.b =b
def add(self):
return a+b
def subtract(self,a,b):
return a-b
def divide(self,a,b):
return a/b
def multiply(self,a,b):
return a/b
if __name__=='__main__':
try:
a = Fraction(input('Please type first fraction '))
b = Fraction(input('Please type second fraction '))
choice = int(input('Please select one of these 1. add 2. subtract 3. divide 4. multiply '))
if choice ==1:
print(Thefraction.add(a,b))
elif choice==2:
print(Thefraction.subtract(a,b))
elif choice==3:
print(Thefraction.divide(a,b))
elif choice==4:
print(Thefraction.multiply(a,b))
except ValueError:
print('Value error!!!!!') …
Run Code Online (Sandbox Code Playgroud) 我有大数据集,并且有大量价值超出平均值。例如,
A B
1 'H' 10
2 'E' 10000
3 'L' 12
4 'L' 8
5 'O' 11
Run Code Online (Sandbox Code Playgroud)
我想将像元设置B2
为0,然后尝试了
df['B'] = df['B'].replace([df['B'] > 15], 0)
Run Code Online (Sandbox Code Playgroud)
但是没有任何运气。如何使我的数据框像这样,
A B
1 'H' 10
2 'E' 0
3 'L' 12
4 'L' 8
5 'O' 11
Run Code Online (Sandbox Code Playgroud)
谢谢!
我有pandas数据帧,一个索引(datetime)和三个变量(int)
date A B C
2017-09-05 25 261 31
2017-09-06 261 1519 151
2017-09-07 188 1545 144
2017-09-08 200 2110 232
2017-09-09 292 2391 325
Run Code Online (Sandbox Code Playgroud)
我可以用基本的熊猫图创建分组条形图.
df.plot(kind='bar', legend=False)
Run Code Online (Sandbox Code Playgroud)
但是,我想在Seaborn或其他图书馆展示,以提高我的技能.
我找到了非常接近的答案(熊猫:如何绘制两个类别和四个系列的条形图?).
在其建议的答案中,它具有代码
ax=sns.barplot(x='', y='', hue='', data=data)
Run Code Online (Sandbox Code Playgroud)
如果我将此代码应用于我的,我不知道我的'y`是什么.
ax=sns.barplot(x='date', y=??, hue=??, data=data)
Run Code Online (Sandbox Code Playgroud)
如何使用Seaborn或其他库绘制多个变量?
python ×5
pandas ×4
dataframe ×3
matplotlib ×3
express ×2
node.js ×2
seaborn ×2
if-statement ×1
java ×1
material-ui ×1
mp3 ×1
reactjs ×1
spring ×1
spring-boot ×1
spring-mvc ×1