有没有办法在python中编写这个c语句?

时间:2018-05-29 18:10:21

标签: python python-3.x

int b = -a++;

$ yarn start yarn run v1.3.2 $ yarn run webpack:dev $ yarn run webpack-dev-server -- --config webpack/webpack.dev.js --progress --inline --profile --port=9060 warning From Yarn 1.0 onwards, scripts don't require "--" for options to be forwarded. In a future version, any explicit "--" will be forwarded as-is to the scripts. $ node --max_old_space_size=4096 node_modules/webpack-dev-server/bin/webpack-dev-server.js --config webpack/webpack.dev.js --progress --inline --profile --port=9060 module.js:557 throw err; ^ Error: Cannot find module '/Users/andrewcarre/Desktop/familyhomestay/node_modules/webpack-dev-server/bin/webpack-dev-server.js' at Function.Module._resolveFilename (module.js:555:15) at Function.Module._load (module.js:482:25) at Function.Module.runMain (module.js:701:10) at startup (bootstrap_node.js:193:16) at bootstrap_node.js:617:3 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. Andrews-MBP:familyhomestay andrewcarre$

有没有办法在python中编写这个表达式? 如果有任何在python中写这个,那么如何在python中编写它?

2 个答案:

答案 0 :(得分:3)

Python中没有++运算符,因此您需要使用多个语句

a = 10
b = -a
a += 1

这实际上并不是什么大不了的事,因为无论如何b = -a++是一件令人困惑的事情。

答案 1 :(得分:2)

你可以尝试(因为用户abarnert也指出)

a = 10
b, a = -a, a+1

将其写入1行。并且代码在其意图中更加明确