Python Learning notes January 8-January 12

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.