var receive = offer.itemsToReceive;
var pass = true;
receive.forEach(function(id) {
var args = id.split(",");
market.getItemPrice("some app id", some item name).then(function(result) {
var json = JSON.parse(JSON.stringify(result)); // returns e.G $0.08
var price = parseFloat(json.median_price.substring(1));
if(price*100 < 100) {
pass = false;
}
});
});
运行此代码时,出现AttributeError。 我正在尝试使用pygal模块将星形最多的python项目绘制到条形图上。该任务来自Eric Matthes的Python速成班。我正在和他交叉检查我的代码,但似乎找不到任何问题
跟踪:
import requests
import pygal
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS
url = "https://api.github.com/search/repositories?
q=language:python&sort=stars"
r = requests.get(url)
response_dict = r.json()
names,stars = [],[]
for repo in repo_dicts:
names.append(repo["name"])
stars.append(repo["stargazers_count"])
my_style = LS("333366", base_style=LCS)
chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)
chart.title = "Most starred Python projects on GitHub"
chart.x_labels = names
chart.add(" ", stars)
chart.render_to_file("repo_visual.svg")
非常感谢您的帮助。
答案 0 :(得分:1)
@SagarJhamb您的代码有两个错误
1.repo_dicts未初始化
2。定义my_style = LS(“ 333366”,base_style = LCS)值应以#333366 开头,以了解有关pygal的自定义样式的更多信息,您可以查看[pygal文档] [1] [1]: http://www.pygal.org/en/stable/documentation/parametric_styles.html
<?xml version="1.0" encoding="utf-8"?>
<!-- Root layout can be anything. Just make sure to include xmlns:app line. -->
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- The RichContentEditText -->
<!-- Notice app:allowedMimeTypes="images"; it is what accepts certain mime types
(you can do this programmatically too) -->
<com.gsconrad.richcontentedittext.RichContentEditText
android:id="@+id/rich_content_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/rich_content_edit_text_hint"
android:inputType="text"
app:allowedMimeTypes="images" />
</android.support.constraint.ConstraintLayout>