我想为使用python后端的应用程序自动创建代码。我希望用python脚本将几行javascript代码添加到js文件中。有人能指导我吗?在python代码中编辑JavaScript文件中的代码
我的代码如下所示:
angular.module('app').config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: '/static/partials/home.html',
controller: 'HomeController'
})
.when('/hello', {
templateUrl: '/static/partials/hello.html',
controller: 'HelloController'
})
}
]);
我想要动态地从后端这是在添加蟒另一个URL“/指数”。
添加代码后,因此,它应该如下所示:
angular.module('app').config(['$routeProvider',
function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: '/static/partials/home.html',
controller: 'HomeController'
})
.when('/hello', {
templateUrl: '/static/partials/hello.html',
controller: 'HelloController'
})
.when('/index', {
templateUrl: '/static/partials/index.html',
controller: 'IndexController'
})
}
]);
您是否希望将文本打印到python文件中?检查[输入和输出文档](https://docs.python.org/3/tutorial/inputoutput.html)。 – PaSTE
我想用python脚本编辑JavaScript文件(.js扩展名)中的代码。 –
这是动态添加代码的错误方法。问题得到了downvote..just试图澄清? –