在Python中拆分数字

时间:2017-10-22 19:07:52

标签: python

我怎么能分开一个号码?例如(10应该看起来像1,2,3,4,5,6,7,8,9,10)

我是初学者,所以请不要疯狂地回答

2 个答案:

答案 0 :(得分:0)

因此你可以简单地使用for循环。 看起来像这样:

`//Register
router.post('/register', (req, res, next) => {
  let newUser = new User({
    name: req.body.name,
    email: req.body.email,
    username: req.body.username,
    password: req.body.password
  });

  var exists;

  User.findOne({
    '$or': [{
      email: req.body.email
    }, {
      username: req.body.username
    }]
  }, function (err, existingUser) {
    if (existingUser) {
      console.log('Email exists');
      exists = true;
    }
    console.log(exists);
    if (exists == true) {
      res.json({
        success: false,
        msg: 'Email or username is already registered'
      })
    }
  });

})`

答案 1 :(得分:-3)

试试这个:

import numpy as np
x = 10
answer = np.arange(1,x+1)

现在回答是一个数字从1到10的数字。