Skip to content
Merged

0023 #129

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions llluiop/0017/student.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python
#-*- coding: utf-8-*-

import xlrd, codecs, json
from lxml import etree


def load_data(file_path):
xls = xlrd.open_workbook(file_path)
sheet = xls.sheet_by_index(0)

data = {}
for i in range(sheet.nrows):
data[str(sheet.row_values(i)[0])] = str(sheet.row_values(i)[1].encode("utf-8"))

return json.dumps(data, encoding="UTF-8", ensure_ascii=False)

def write_data_to_xls(data):
xml = codecs.open("student.xml", "w", encoding="utf-8")

ele_root = etree.Element("root")
xml_root = etree.ElementTree(ele_root)
xml_student = etree.SubElement(ele_root, "students")
#xml_student.append(etree.Comment(u'ѧ����Ϣ��\n\"id\": [���֣���ѧ�����ģ�Ӣ��]'))
xml_student.text = str(data)

xml.write(etree.tounicode(xml_root.getroot()))
xml.close()


if __name__ == '__main__':
data = load_data("student.xls")
write_data_to_xls(data)




Binary file added llluiop/0017/student.xls
Binary file not shown.
Empty file added llluiop/0017/student.xml
Empty file.
Empty file.
114 changes: 114 additions & 0 deletions llluiop/0023/MyDjango/MyDjango/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
"""
Django settings for MyDjango project.
Generated by 'django-admin startproject' using Django 1.9.
For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'mq8x9rt)5b@_(&^25ca%&jj+e&)xn4@y&2bg#it*uugwz4h&l*'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'web'
]

MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
]

ROOT_URLCONF = 'MyDjango.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'MyDjango.wsgi.application'


# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}


# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'

TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
'web',
)

STATICFILES_DIRS = (

os.path.join(BASE_DIR, 'static'),

)
34 changes: 34 additions & 0 deletions llluiop/0023/MyDjango/MyDjango/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""MyDjango URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/dev/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Add an import: from blog import urls as blog_urls
2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from web.views import current_time
from web.views import add
from web.views import person
from web.views import home
from web.views import board
from web.views import postmessage

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^time/', current_time),
url(r'^add/(\d+)/(\d+)', add),
url(r'^home', home),
url(r'^person', person),
url(r'^board', board, name='board'),
url(r'^postmessage/$', postmessage, name='postmessage')

]
16 changes: 16 additions & 0 deletions llluiop/0023/MyDjango/MyDjango/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for MyDjango project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyDjango.settings")

application = get_wsgi_application()
Binary file added llluiop/0023/MyDjango/db.sqlite3
Binary file not shown.
10 changes: 10 additions & 0 deletions llluiop/0023/MyDjango/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MyDjango.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Loading