「コーダーの見習い:Python 3で学習する」(http://www.spronck.net/pythonbook/pythonbook.pdf)を使用しています。「The」という単語が、印刷機能に構文エラーを引き起こしています - Python
「この本のカバー価格は24.95ドルですが、書店には40%の割引があります。 送料は、最初のコピーでは3ドル、追加のコピーでは75セントです。 60枚分。
これは私のコードです:何らかの理由
book_price = 24.95
book_discount = book_price/10 * 4
bookstore_book_price = book_price - book_discount
shipping_first = 3
shipping_rest = 0.75
sixty_shipped = bookstore_book_price + shipping_first + (shipping_rest * 59)
print("A book is being sold regularly for " +str(book_price) + ".")
print("At bookstores, it's being sold with a 40% discount, amounting to " + str(book_discount) + ".")
print("This means it's being sold at bookstores for " + str(bookstore_book_price) + ".")
print("The first copy ships for " + "str(shipping_first) + ", but the rest ships for " + str(shipping_rest) ".")
print("Given 60 copies were shipped, it would cost " + str(sixty_shipped + ".")
、単語のコード行でthe
:
(print("The first copy ships for " + "str(shipping_first) + ", but the rest ships for " + str(shipping_rest) "."))`
は、構文エラーを生成します。私がfor
に達するまで私は各単語を削除することを考えると、私はまだ構文エラーを取得します。のみfor
とbut
が残っている場合は、エラー:
EOL while scanning string literal
が生成されます。私は何をすべきかわからない。あなたは余分な"
を得たのでUsing IDLE editor (not prompt).
'' str(shipping_first) 'で' ''を削除してください。また、あなたは '' str.format'(https:/)を見てみたいかもしれませんが、 '' str(shipping_rest) ''の後に '' str(sixty_shipped') /docs.python.org/3/library/stdtypes.html#str.format) –
Stackoverflows構文のHightlighterでもエラーが表示されます:) –
引用符が一致しません。 'print'の中の文字列の書式からそれをはっきりと見ることができます –