This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#注释 | |
shu=10000 | |
result=[a for a in range(1,shu+1) if shu%a==0] | |
print(result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding=utf-8 | |
import os | |
def countlines(thefile): | |
lines=0 | |
with open(thefile) as f: | |
for line in f.readlines(): | |
if len(line)>1: | |
# print line | |
lines=lines+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#媒体文件上传(本地)位置 | |
MEDIA_ROOT=os.path.join(BASE_DIR,'moping/static/media/') | |
if ONLINE: | |
MEDIA_URL = 'http://mp360-img.stor.sinaapp.com/' | |
else: | |
MEDIA_URL = '/static/media/' | |
STATIC_ROOT = 'moping/static' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# project下的urls.py | |
urlpatterns = patterns('', | |
url(r'^admin/', include(admin.site.urls)), | |
url(r'', include('account.urls')), | |
# url(r'^ac/', include('account.urls')), | |
) | |
#account的app下urls.py文件 | |
urlpatterns = patterns('account.views', | |
url(r'^$','index',name='indexpage'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ datetimeField|date:'Y-m-d H:i' }} | |
{{ datetimeField|timesince }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProjectStyle(models.Model): | |
name=models.CharField(max_length=50) | |
def __unicode__(self): | |
return self.name | |
class GuanZhu(models.Model): | |
guanzhu=models.ForeignKey(ProjectStyle) | |
user=models.ForeignKey(BaseInfo,related_name='guanzhus') | |
# 可以通过在模板中如下使用 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 在模板html文件顶部加入下面这行 | |
{% load staticfiles %} | |
# 在使用静态文件的地方用: | |
<img src="{% static user.touxiang %}" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#从第7行+后面4行,整体代码左移一个tab位置 | |
7gg4<< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!python | |
"""Bootstrap distribute installation | |
If you want to use setuptools in your package's setup.py, just include this | |
file in the same directory with it, and add this to the top of your setup.py:: | |
from distribute_setup import use_setuptools | |
use_setuptools() | |
If you want to require a specific version of setuptools, set a download |
This file has been truncated, but you can view the full file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Hi There! | |
# You may be wondering what this giant blob of binary data here is, you might | |
# even be worried that we're up to something nefarious (good for you for being | |
# paranoid!). This is a base64 encoding of a zip file, this zip file contains | |
# an entire copy of pip. | |
# | |
# Pip is a thing that installs packages, pip itself is a package that someone | |
# might want to install, especially if they're looking to run this get-pip.py |
OlderNewer