似乎我使用{% extends "base.html" %}它正确地继承了模板,但导航栏不使用bootstrap.
如果我使用{% extends "bootstrap/base.html" %}它甚至不起作用.我没有得到错误,但它只是将标题设置为索引,然后页面为空.
另一个注意事项:我让导航栏出现的唯一方法是将其直接放入index.html并使用{% extends "bootstrap/base.html" %}
我正在使用Miguel Grinberg的Flask Web Development,除了明显的内容之外,代码是相同的.
我究竟做错了什么?有没有人有足够的资源慢慢跳进Flask,而不是先潜入水中?我无法理解这些小细节.
base.html文件:
{% extends "bootstrap/base.html" %}
<html>
<head>
{% block head %}
<title>{% block title %}{% endblock %} - MyFlask</title>
{% endblock %}
</head>
<body>
{% block navbar %}
<div class="navbar navbar-inverse" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Navbar</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">MyFlask</a>
</div> …Run Code Online (Sandbox Code Playgroud) 我正在练习os模块,更具体地说os.walk().我想知道是否有一种更简单/更有效的方法来查找文件的实际路径,因为这会产生一条路径,表明文件在os.walk()首次运行时位于原始文件夹中:
import os
threshold_size = 500
for folder, subfolders, files in os.walk(os.getcwd()):
for file in files:
filePath = os.path.abspath(file)
if os.path.getsize(filePath) >= threshold_size:
print filePath, str(os.path.getsize(filePath))+"kB"
Run Code Online (Sandbox Code Playgroud)
这是我目前的解决方法:
import os
threshold_size = 500
for folder, subfolders, files in os.walk(os.getcwd()):
path = os.path.abspath(folder)
for file in files:
filePath = path + "\\" + file
if os.path.getsize(filePath) >= threshold_size:
print filePath, str(os.path.getsize(filePath))+"kB"
Run Code Online (Sandbox Code Playgroud)
对于shaktimaan,这个:
for folder, subfolders, files in os.walk(os.getcwd()):
for file in files:
filePath = os.path.abspath(file)
print …Run Code Online (Sandbox Code Playgroud)