【发布时间】:2014-08-29 03:00:31
【问题描述】:
我是一个初学者,所以我什至不知道执行此操作的最佳方法或如何称呼我正在尝试做的事情,但我正在制作一个事件发布应用程序,该应用程序将具有当月的标题和年如this jsfiddle。
var calendar = angular.module('calendar', []);
calendar.controller('month_and_year', ['$scope', function ($scope) {
$scope.month = {{current_month}};
$scope.year = {{current_year}};
$scope.month_names = ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
$scope.add_one = function () {
if ($scope.month == 12) {
$scope.year++;
$scope.month = 1;
} else {
$scope.month++
}
};
$scope.sub_one = function () {
if ($scope.month == 1) {
$scope.year--;
$scope.month = 12;
} else {
$scope.month--
}
};
}]);
我的 Python 的重要部分如下所示:
import datetime
now = datetime.datetime.now()
current_month=now.month
current_year=now.year
def get_days_for_dates(year):
dates = calendar.Calendar().yeardayscalendar(year)
days_of_week= ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
dates_list=[]
days_list=[]
for quarter in dates:
for month in quarter:
for week in month:
for i in range(len(week)):
dates_list.append(week[i])
days_list.append(days_of_week[i])
return days_list, dates_list
calendar_tuple = get_days_for_dates(current_year)
所以我的问题是我想在我的 Python 中使用 $scope.year,其中 current_year 是使用日历模块并得出每个日期在一周中的哪一天。将此信息发送到后端的最佳方法是什么?
【问题讨论】:
标签: javascript python angularjs flask