我在我的mac上使用Flask(python包),当我第一次写我的css时显示确定.但是,当我更新它并尝试检查它时,我只看到第一个CSS样式.我尝试重新启动终端,以及重新安装Flask.有什么建议?谢谢.继承人HTML:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<header>
<div class="header"></div>
<div class="logo">
<center><img src="/static/img/p_logo.png" alt="pic"/></center>
</div>
</header>
<div class="container">
{% block content %}
{% endblock %}
</div>
</body>
Run Code Online (Sandbox Code Playgroud)
还有CSS:
* {
font-family: "Times New Roman", Times, serif;
}
header {
background-color: #000000;
width: 100%;
height: 7px;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Matplotlib和MPLD3来创建可以在html plages中显示的图形(使用django).目前,我的图表是从csv文件中提取的数据动态生成的.我经常在终端收到这条消息:
运行时警告:已打开超过20个数字.通过pyplot接口(
matplotlib.pyplot.figure)创建的数字将保留,直到明确关闭,并可能消耗太多内存.(要控制此警告,请参阅rcParamfigure.max_num_figures).max_open_warning,RuntimeWarning)
我不确定它的意思,但我假设它意味着我应该有一些方法来关闭未使用的图形.无论如何要做到这一点还是完全偏离基地?谢谢.
我在Macbook Air上运行小牛队.今天我通过他们的网站下载了wxPython,但是当我点击安装包时,我得到了:
wxPython3.0-osx-cocoa-py2.7.pkg” is damaged and can’t be opened. You should eject the disk image.
Run Code Online (Sandbox Code Playgroud)
任何人都有任何想法来解决这个问题,谢谢.
我正在使用Django模型为表单创建字段.我希望自动检测用户的用户名并填写,这样我就可以将其隐藏在我的表单中(而不是让他们从包含每个用户名的长列表中选择他们的用户名).为此,我使用:
current_user = request.user
Run Code Online (Sandbox Code Playgroud)
然后将默认值设置为current_user.但是,我不断收到此错误:
NameError: name 'request' is not defined
Run Code Online (Sandbox Code Playgroud)
我假设你不能在Django模型中使用请求,但无论如何都可以解决这个问题?这是我的models.py文件的相关部分:
class StockTickerSymbol(models.Model):
StockName = models.CharField(max_length=7, unique=True)
current_user = request.user
user = models.ForeignKey(User, default=current_user)
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何在我的模型中使用请求,或以某种方式调用变量current_user?
我在 python 中使用 urllib 从雅虎财经获取股票价格。到目前为止,这是我的代码:
import urllib
import re
name = raw_input(">")
htmlfile = urllib.urlopen("http://finance.yahoo.com/q?s=%s" % name)
htmltext = htmlfile.read()
# The problemed area
regex = '<span id="yfs_l84_%s">(.+?)</span>' % name
pattern = re.compile(regex)
price = re.findall(pattern, htmltext)
print price
Run Code Online (Sandbox Code Playgroud)
所以我输入一个值,股票价格就出来了。但到目前为止我可以让它显示价格,只是一个空白的[]。我已经评论过我认为问题出在哪里。有什么建议么?谢谢。
我正在使用大量CSV文件,每个文件包含大量行。我的目标是逐行获取数据,然后使用Python将其写入数据库。但是,因为有大量数据,所以我想跟踪已写入的数据量。为此,我计算了排队的文件数量,并在文件完成时继续添加一个。
我想对CSV文件执行类似的操作,并显示我所在的行以及总共有多少行(例如:)Currently on row 1 of X。我可以很容易地从第一行开始,然后执行以下操作:currentRow += 1,但是我不确定如何通过耗时的阅读行来获得总计。
另外,由于我的CSV文件都存储在zip归档文件中,因此我目前正在使用ZipFile模块读取它们,如下所示:
#The Zip archive and the csv files share the same name
with zipArchive.open(fileName[:-4] + '.csv', 'r') as csvFile:
lines = (line.decode('ascii') for line in csvFile)
currentRow = 1
for row in csv.reader(lines):
print(row)
currentRow += 1
Run Code Online (Sandbox Code Playgroud)
关于如何快速获取CSV文件总行数的任何想法?
我正在尝试使用Matplotlib绘制烛台图表,以及我为REST API调用获取的数据.但是,由于调用使用了唯一的访问令牌,因此我已下载了一个示例数据并将其加载到csv中以用于此问题.这是一个指向示例数据的pastebin链接.要在Python中处理数据,我使用Pandas来创建数据帧.这是我的代码的样子:
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import matplotlib.dates as mdates
from matplotlib.finance import candlestick_ohlc
from datetime import date
""" Pandas """
historic_df = pd.read_csv("sample_data.csv")
dates = pd.to_datetime(historic_df['time'], format="%Y-%m-%dT%H:%M:%S.%fZ")
openp = historic_df['openAsk']
highp = historic_df['highAsk']
lowp = historic_df['lowAsk']
closep = historic_df['closeAsk']
""" Matplotlib """
ax1 = plt.subplot2grid((1,1), (0,0))
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M:%S'))
x = 0
ohlc = []
while x < len(dates):
d = mdates.date2num(dates[x])
append_me = d, openp.values[x], highp.values[x], lowp.values[x], closep.values[x] …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用pip在Debian Jessie上安装TA-Lib.但是我遇到以下错误:
#include "ta-lib/ta_defs.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
这只是错误的一小部分.我试过这个帖子提到安装以下包:
sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev
sudo easy_install greenlet
sudo easy_install gevent
Run Code Online (Sandbox Code Playgroud)
没有太多运气.我在VPS上使用python 3.4,如果它有所作为.关于如何解决这个问题的任何想法?谢谢