Skip to content

Commit

Permalink
nothing
Browse files Browse the repository at this point in the history
  • Loading branch information
s1031432 committed Dec 26, 2019
1 parent 747981c commit af49ecf
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 2 deletions.
128 changes: 128 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello world!\n"
]
}
],
"source": [
"print(\"Hello world!\")"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'name' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-1-6ac6fd115577>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mclassmate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\"A\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscore\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m49\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\"B\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscore\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m87\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\"C\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscore\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m55\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m{\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\"D\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mscore\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;36m5\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'name' is not defined"
]
}
],
"source": [
"classmate = [{name:\"A\", score:49}, {name:\"B\", score:87}, {name:\"C\", score:55}, {name:\"D\", score:5}];"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': 'A', 'score': 49}"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"classmate = [{\"name\":\"A\", \"score\":49}, {\"name\":\"B\", \"score\":87}, {\"name\":\"C\", \"score\":55}, {\"name\":\"D\", \"score\":5}]\n",
"classmate[0]"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'name': 'A', 'score': 49}, {'name': 'C', 'score': 55}, {'name': 'D', 'score': 5}]\n"
]
}
],
"source": [
"import json\n",
"results = []\n",
"classmate = [\n",
" {\"name\":\"A\", \"score\":49},\n",
" {\"name\":\"B\", \"score\":87}, \n",
" {\"name\":\"C\", \"score\":55}, \n",
" {\"name\":\"D\", \"score\":5}\n",
"]\n",
"for i in classmate:\n",
" if i[\"score\"] < 60:\n",
" results.append(i)\n",
"print(results)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
9 changes: 7 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,11 @@ function getRating(itemid, shopid, ratingOffset){
else if(res.statusCode==200){
//console.log(body);
ratingOffset+=5;
for(var i=0;i<body.data.ratings.length;i++)
for(var i=0;i<body.data.ratings.length;i++){
// vvvvvvvvvv you can write write file(comment) code to replace console vvvvvvvvvv
console.log("\x1b[33m", parseInt(ratingOffset+i-4)+"/"+body.data.item_rating_summary.rating_total, "\x1b[0m\x1b[33m", body.data.ratings[i].rating_star+"\x1b[0m星", body.data.ratings[i].comment);
// ^^^^^^^^^^ you can write write file(comment) code to replace console ^^^^^^^^^^
}
ratingTotal = body.data.item_rating_summary.rating_total;
if(ratingTotal <= ratingOffset){
keywordOffset++; // conitue next item
Expand All @@ -64,12 +67,14 @@ function getRating(itemid, shopid, ratingOffset){
var keywordOffset=0;
function main(){
// put keyword vvvvvvv
var keyword = "Canon 50mm";
var keyword = "針織上衣";
// put keyword ^^^^^^^
getId(keyword, keywordOffset)
.then(function (fullfilled){
ratingTotal=-1;
// vvvvvvvvvv you can write write file(title) code to replace console vvvvvvvvvv
console.log(" --以下為 ", "\x1b[33m", fullfilled.items[0].name+"\x1b[0m", " 的評論--");
// ^^^^^^^^^^ you can write write file(title) code to replace console ^^^^^^^^^^
getRating(fullfilled.items[0].itemid, fullfilled.items[0].shopid, 0)
.then(function(fullfilled){

Expand Down

0 comments on commit af49ecf

Please sign in to comment.