Goal: The intention is to spend two or three weeks almost, less than one months to contact Python, Baidu can use the crawler what, do something personal to interest, and in the middle of the year to buy a "redis combat" inside is a python example. I also ate the ashes for a long time.
January 8
Look at the ebook, "Python Programming: from getting started to practicing," and looking at page 80 for a day. Section 9.1 Create and use classes.
Look very slow, efficiency is much lower than I thought, the beginning of the introduction of the basic variable, spent too much time, but not to see. And big bored, super want to abandon forget.
Later in the afternoon to see the function class, began to have a little meaning. Finally, not just boring introduction.
Then follow the 9.1 section began to create a new class, found that the error is not known, see the error prompt, I have been looking for a long time. Finally Baidu a bit error hint, hh, originally is the TAB key and space bar together with, although can not see, but really does not match the line. Depressed... Baidu will save a lot of time if you start by mistake.
See here first, the paddle continues tomorrow.
Attach today's small general Section code
1 classRestaurant:2 def __init__(Sell, user_name, User_type, * *user_info):3Sell.userinfo = {}4Sell.user_name =user_name5Sell.user_type =User_type6 forKey, ValinchUser_info.items ():7Sell.userinfo[key] =Val8 defdescribe_restaurant (Sell):9 Print("name is"+ sell.user_name.title () +", type is" Ten+ sell.user_type.title () +"\ n") One Print("User_info is \ n") A Print(Sell.userinfo) - defHello (Sell): - ifSell.user_type = ='Admin': the Print("Hello admin") - Else: - Print("Hello"+ sell.user_name)
View Code
1 from Import *23 my_luck = Restaurant ('panhaowei',' Admin', sex='man', like='book' )4my_luck.describe_restaurant ()5 My_luck.hello ()
View Code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python Learning notes January 8-January 12