Home > other >  Small white for help. Use python2.7 row_input input string, can't read out
Small white for help. Use python2.7 row_input input string, can't read out

Time:11-23

 book_name=raw_input (" both please input the order: "). The decode (encoding="utf-8") 
Print book_name
If book_name books_list in:
Print (' the book belongs to Numbers for: % d number. The decode (' utf-8) encode (' GBK) % books_list [book_name])
The else:
Print (u 'no such book')


Can read out the title of the print out, but will find it in the dict books_list, has been ascertained, I think it is a coding problem, search the answer to the following on the Internet, seems to still can not solve, ask everybody to help, just a few days to start learning python,

CodePudding user response:

1. Look from the indentation of your code very confusion - "post code copy out you can't run

So still trouble you, reference:
Learn to map and post code - CSDN, BBS BBS Python beginner, small white common errors and problems
Code to post, complete, accurate,

Convenient and then others will help you find out your problem,

2. Also:
You here
Books_list
Didn't stick out the value of the
Code is not complete, others also not good for you,
As far as possible can stick out, put out,

CodePudding user response:

reference 1st floor crifan response:
1. Looked from the indentation of your code very confusion - "post code copy out you can't run

So still trouble you, reference:
Learn to map and post code - CSDN, BBS BBS Python beginner, small white common errors and problems
Code to post, complete, accurate,

Convenient and then others will help you find out your problem,

2. Also:
You here
Books_list
Didn't stick out the value of the
Code is not complete, others also not good for you,
As far as possible can stick out, post,


That I posted a picture
When I enter the university, but still hint check without the book, but can print book_name is printed, I think is coding problem, search using the decode method but still can not solve, thank you ~

CodePudding user response:

The upgrade environment, in the book, 2.7 out of date,

CodePudding user response:

reference 4 floor chuifengde response:
the upgrade environment, in the book, 2.7 obsolete,

2.7 can't ah, the teacher asked us to learn

CodePudding user response:

Obviously is: you the original code, excessive to the string to encode and decode cause for beginners you ugly out problems,
As for the details: too lazy to reply,
Because of you, also too lazy to post code,
- "advised that let you post the code you don't listen to,
So do I want to help you, and I knock to asm code
- "is a waste of my time, you solve it for you,

CodePudding user response:

refer to 6th floor crifan response:
is obviously: your original code, excessive to the string to encode and decode cause for beginners you ugly out problems,
As for the details: too lazy to reply,
Because of you, also too lazy to post code,
- "advised that let you post the code you don't listen to,
So do I want to help you, and I knock to asm code
- "is a waste of my time, you solve it for you,

Ok, thank you ~

CodePudding user response:

Python is the default utf-8, you use is GBK, can take out to read?

CodePudding user response:

 
Print (' the book belongs to Numbers for: % d number. The decode (' utf-8) encode (' GBK) % books_list [book_name])
Try # is changed to the following
Print (' the book belongs to Numbers for: % d % books_list [book_name])
  • Related