我的git代码仓库: [https://code.aliyun.com/whjwnavy] or [https://github.com/WHJWNAVY]

Python学习:Python快速入门

设计语言 WHJWNAVY 452℃ 91评论

#输入输出

################################################################################

#name = input("Please Input Your Name:")

#print("Your Name:",name)

print("123 + 234 = "123 + 234)

 
 

 
 

#转义字符

################################################################################

print("\\\r\n\t\\")

print(r"\\\r\n\t\\")

#在需要在字符中使用特殊字符时,python用反斜杠(\)转义字符。如下表:

转义字符

描述

\(在行尾时)

续行符

\\

反斜杠符号

\'

单引号

\"

双引号

\a

响铃

\b

退格(Backspace)

\e

转义

\000

\n

换行

\v

纵向制表符

\t

横向制表符

\r

回车

\f

换页

\oyy

八进制数,yy代表的字符,例如:\o12代表换行

\xyy

十六进制数,yy代表的字符,例如:\x0a代表换行

\other

其它的字符以普通格式输出

 
 

#字符串分行

################################################################################

print('''Hello

World''')

 
 

 
 

#布尔运算

################################################################################

print("3 > 2            ?"3>2)

print("3 < 2            ?"3<2)

print("True and False   ?"True and False)

print("True or False    ?"True or False)

print("not False        ?"not False)

 
 

 
 

#变量赋值

################################################################################

a = 100

print("a =", a)

a = "aaa"

b = a

a = "bbb"

print("a =", a)

print("b =", b)

 
 

 
 

#常量

################################################################################

#Python中用全部大写的变量表示常量,

#但实际上它仍然是可以被更改的

PI = 3.1415926

print("PI = ", PI)

 
 

 
 

#浮点除和整除

################################################################################

print("10 / 2 ="10/2)#浮点除

print("9 / 2  ="9/2)#浮点除

print("10 // 2 ="10//2)#整除

print("9 // 2  ="9//2)#整除

 
 

 
 

#字符串编码

################################################################################

#对于单个字符的编码,Python提供了ord()函数获取

#字符的整数表示,chr()函数把编码转换为对应的字符

print(ord("A"))

print(ord(""))#unicode编码

print(chr(66))

print(chr(25991))

 
 

 
 

#条件判断

################################################################################

age = 3

if age >= 18:

    print('adult')#Pythontab区分代码块

elif age >= 6:

    print('teenager')

else:#不要忘了冒号

    print('kid')

    #pass

    # pass语句什么都不做,那有什么用?实际上pass可以用来作为占位符,

    比如现在还没想好怎么写函数的代码,就可以先放一个pass,让代码能

    运行起来

 
 

#s = input('birth: ')

#birth = int(s)#把数值字符串转化成整数

#if birth < 2000:

#    print('00')

#else:

#    print('00')

 
 

 
 

#for循环

################################################################################

#for x in ...循环就是把每个元素代入变量x,然后执行缩进块的语句。

 
 

students = ["小红""小明""小芳""小玉"]

for x in students:

    print(x)

 
 

#rangexrange

################################################################################

#range([start,] stop[, step]),根据startstop指定的范围以及step设定

#的步长,生成一个序列。xrange用法与range完全相同,所不同的是range

#直接生成一个list对象,xrange则不会直接生成一个list,而是每次调用返

#回其中的一个值。要生成很大的数字序列的时候,用xrange会比range性能优很多

 
 

#Python 3 中已经没有了 xrange

 
 

sumx = 0

for x in range(11011):

    sumx = sumx + x

    #print(x)

print("1+2+3+...+100 =", sumx)

 
 

#while循环

################################################################################

sumn = 0

n = 1

while n <= 1000:

    sumn = sumn + n

    n = n + 1

    #print(n)

print("1+2+3+...+1000 =", sumn)

转载请注明:胡椒小兄弟 » Python学习:Python快速入门

喜欢 (0)or分享 (0)
发表我的评论
取消评论
表情 签到
(91)个小伙伴在吐槽
  1. 你好啊
    匿名2017-10-19 15:05 回复
  2. I just want to mention I am just very new to blogging and site-building and absolutely savored your web-site. More than likely I’m planning to bookmark your site . You absolutely have fantastic stories. Bless you for revealing your webpage.
    Read More Here2018-01-31 17:56 回复
  3. I do not even know how I ended up here, but I thought this post was great. I do not know who you are but definitely you are going to a famous blogger if you are not already 😉 Cheers!
    solomon2crm.com2018-02-02 20:03 回复
  4. I'm so happy to read this. This is the type of manual that needs to be given and not the random misinformation that's at the other blogs. Appreciate your sharing this best doc.
    nationstar mortgage2018-02-02 20:39 回复
  5. Valuable information. Lucky me I discovered your web site unintentionally, and I'm surprised why this accident didn't took place in advance! I bookmarked it.
    aoflibrary.net2018-02-03 15:03 回复
  6. Thank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how can we communicate?
  7. Thanks , I have recently been searching for information about this topic for a while and yours is the greatest I've found out till now. However, what about the bottom line? Are you positive concerning the source?
    5aswiss.com2018-02-03 20:04 回复
  8. There is noticeably big money to understand about this. I suppose you made particular nice points in features also.
    匿名2018-02-03 22:15 回复
  9. As I website possessor I believe the content matter here is rattling great , appreciate it for your efforts. You should keep it up forever! Best of luck.
    chanelpascher.com2018-02-06 01:27 回复
  10. hi!,I like your writing very a lot! proportion we be in contact more approximately your article on AOL? I require an expert on this house to solve my problem. May be that is you! Having a look ahead to look you.
    consultarnumero.com2018-02-06 04:22 回复
  11. Thank you for any other informative website. Where else could I get that kind of information written in such a perfect approach? I have a project that I am just now operating on, and I have been on the glance out for such information.
    kitchen remodel2018-02-06 06:50 回复
  12. Fantastic goods from you, man. I have understand your stuff previous to and you are just too wonderful. I really like what you've acquired here, certainly like what you are stating and the way in which you say it. You make it enjoyable and you still care for to keep it smart. I can not wait to read far more from you. This is really a terrific website.
    brandsfavor.com2018-02-06 12:05 回复
  13. I recently located your web a few days back and I also happen to be looking through it regularly. you have got a great vary of effective facts on the positioning and I also furthermore really love the precise style of the spot at very same time. carry on the best work!
    Yaeko Ragland2018-02-06 19:17 回复
  14. I simply wanted to appreciate you once more. I'm not certain the things I would have carried out without the tactics provided by you relating to my situation. Previously it was the distressing issue in my opinion, nevertheless seeing your specialized avenue you dealt with that took me to cry with fulfillment. I am happier for this advice and thus pray you recognize what a great job you're carrying out teaching many people through your webpage. I am certain you've never met any of us.
  15. I have been absent for some time, but now I remember why I used to love this web site. Thank you, I will try and check back more often. How frequently you update your site?
    gshguide.com2018-02-07 10:48 回复
  16. I am commenting to make you know of the brilliant encounter my daughter enjoyed reading your webblog. She noticed so many pieces, which include how it is like to possess a wonderful giving nature to let other folks without problems learn selected complicated matters. You undoubtedly did more than visitors' desires. Many thanks for giving such valuable, trustworthy, revealing not to mention unique tips on this topic to Sandra.
    crammonduk.com2018-02-07 11:12 回复
  17. I¡¦ll immediately grasp your rss as I can't in finding your e-mail subscription link or e-newsletter service. Do you have any? Kindly let me know so that I could subscribe. Thanks.
    nationstar mortgage2018-02-07 13:35 回复
  18. Wow! This could be one particular of the most beneficial blogs We've ever arrive across on this subject. Basically Fantastic. I'm also an expert in this topic therefore I can understand your effort.
    Fashion2018-02-07 15:46 回复
  19. I have not checked in here for a while since I thought it was getting boring, but the last several posts are good quality so I guess I'll add you back to my everyday bloglist. You deserve it my friend :)
    Fashion2018-02-08 01:37 回复
  20. Pretty nice post. I just stumbled upon your blog and wished to say that I have truly enjoyed surfing around your blog posts. After all I will be subscribing to your feed and I hope you write again soon!
    ircyb.org2018-02-08 03:56 回复
  21. I dugg some of you post as I cogitated they were extremely helpful extremely helpful
    Home Improvement2018-02-08 16:27 回复
  22. I cling on to listening to the news broadcast talk about receiving free online grant applications so I have been looking around for the most excellent site to get one. Could you tell me please, where could i acquire some?
    blackfloortiles.com2018-02-08 17:42 回复
  23. I don’t even know how I ended up here, but I thought this post was good. I don't know who you are but definitely you're going to a famous blogger if you are not already 😉 Cheers!
  24. I loved as much as you'll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike.
    effortlessrun.com2018-02-09 01:14 回复
  25. I think other web-site proprietors should take this web site as an model, very clean and fantastic user friendly style and design, let alone the content. You're an expert in this topic!
    arts & design2018-02-09 02:27 回复
  26. Well I truly liked reading it. This subject offered by you is very constructive for good planning.
  27. Needed to send you that little bit of remark so as to give many thanks once again for your personal breathtaking secrets you've featured on this page. This is simply tremendously open-handed of people like you to offer openly all that most people would've advertised as an e book to help make some profit on their own, specifically considering the fact that you might have done it if you ever desired. These ideas likewise acted to be the fantastic way to understand that some people have the identical zeal just as my own to know the truth many more when it comes to this condition. I believe there are millions of more enjoyable occasions ahead for those who read through your website.
    for sale by owner2018-02-09 02:53 回复
  28. Very interesting subject, regards for posting.
    Home Improvement2018-02-09 04:43 回复
  29. Thank you for the sensible critique. Me & my neighbor were just preparing to do a little research about this. We got a grab a book from our area library but I think I learned more clear from this post. I'm very glad to see such great info being shared freely out there.
    News2018-02-09 15:12 回复
  30. Only a smiling visitor here to share the love (:, btw outstanding design and style .
    News2018-02-10 00:00 回复
  31. of course like your web-site however you need to check the spelling on several of your posts. A number of them are rife with spelling problems and I to find it very troublesome to inform the reality however I'll certainly come back again.
    News2018-02-10 15:15 回复
  32. This is very interesting, You are a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your site in my social networks!
  33. It¡¦s actually a cool and helpful piece of info. I am satisfied that you just shared this helpful information with us. Please stay us informed like this. Thanks for sharing.
    faturaodemeleri.com2018-02-10 22:17 回复
  34. I do agree with all the ideas you've presented to your post. They're very convincing and can definitely work. Still, the posts are very brief for starters. May just you please lengthen them a bit from next time? Thank you for the post.
    News2018-02-11 04:19 回复
  35. Perfectly composed written content , appreciate it for information .
    News2018-02-11 17:17 回复
  36. Enjoyed reading through this, very good stuff, appreciate it. "It is in justice that the ordering of society is centered." by Aristotle.
    Fashion2018-02-12 06:48 回复
  37. I'll right away clutch your rss feed as I can not in finding your email subscription link or newsletter service. Do you've any? Kindly let me understand in order that I could subscribe. Thanks.
    News2018-02-12 18:01 回复
  38. Someone essentially lend a hand to make severely articles I'd state. That is the first time I frequented your web page and up to now? I surprised with the research you made to make this actual put up incredible. Excellent task!
    News2018-02-13 02:56 回复
  39. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you could do with a few pics to drive the message home a bit, but instead of that, this is wonderful blog. A fantastic read. I'll definitely be back.
  40. I like what you guys are up too. Such intelligent work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my website :).
    News2018-02-13 22:38 回复
  41. Somebody necessarily assist to make significantly posts I might state. That is the very first time I frequented your website page and to this point? I surprised with the analysis you made to create this actual post extraordinary. Great activity!
    News2018-02-14 06:53 回复
  42. Very interesting details you have remarked, appreciate it for posting . "The biggest fool may come out with a bit of sense when you least expect it." by Eden Phillpotts.
    Fashion2018-02-14 15:04 回复
  43. I truly appreciate this post. I have been looking all over for this! Thank goodness I found it on Bing. You have made my day! Thanks again!
    Home Improvement2018-02-15 05:21 回复
  44. I was looking at some of your posts on this internet site and I think this internet site is very informative ! Continue putting up.
    Home Improvement2018-02-15 14:11 回复
  45. Hello my loved one! I want to say that this post is amazing, nice written and come with almost all important infos. I'd like to see more posts like this.
    Home Improvement2018-02-16 02:46 回复
  46. Very interesting subject , appreciate it for putting up. "The season of failure is the best time for sowing the seeds of success." by Paramahansa Yogananda.
    News2018-02-16 17:26 回复
  47. I'm extremely impressed with your writing skills and also with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, it is rare to see a nice blog like this one nowadays..
    new electronics2018-02-17 00:56 回复
  48. We're a group of volunteers and opening a new scheme in our community. Your site provided us with valuable info to work on. You've done an impressive job and our whole community will be grateful to you.
    contractions2018-02-17 00:56 回复
  49. I've learn a few good stuff here. Definitely price bookmarking for revisiting. I wonder how so much attempt you set to make this sort of fantastic informative web site.
    Home Improvement2018-02-17 02:31 回复
  50. I conceive you have noted some very interesting details , regards for the post.
    Home Improvement2018-02-17 18:40 回复
  51. You really make it seem so easy with your presentation but I find this topic to be actually something which I think I would never understand. It seems too complex and very broad for me. I'm looking forward for your next post, I will try to get the hang of it!
  52. Hello there, I found your site via Google whilst searching for a related subject, your website came up, it appears to be like good. I have bookmarked it in my google bookmarks.
    cheap plane tickets2018-02-18 03:01 回复
  53. I wish to get across my respect for your generosity in support of women who have the need for assistance with the subject matter. Your special dedication to getting the solution all-around had been incredibly valuable and have consistently encouraged employees like me to reach their aims. Your new interesting information signifies much a person like me and further more to my fellow workers. Best wishes; from everyone of us.
    vacation packages2018-02-18 03:01 回复
  54. I gotta favorite this web site it seems very useful handy
    Health2018-02-18 03:12 回复
  55. Hi there, just became alert to your blog through Google, and found that it is truly informative. I’m going to watch out for brussels. I will be grateful if you continue this in future. Many people will be benefited from your writing. Cheers!
  56. You are my intake , I possess few web logs and very sporadically run out from to post .
    Home Improvement2018-02-18 16:07 (7天前)回复
  57. I've learn some good stuff here. Certainly price bookmarking for revisiting. I surprise how so much attempt you place to create one of these excellent informative website.
    Home Improvement2018-02-18 23:39 (7天前)回复
  58. You are my intake , I have few web logs and occasionally run out from to post .I believe this web site has got some real fantastic info for everyone. "To be able to be caught up into the world of thought -- that is being educated." by Edith Hamilton.
    Fashion2018-02-19 13:30 (6天前)回复
  59. It's actually a great and useful piece of information. I'm happy that you shared this useful information with us. Please keep us up to date like this. Thank you for sharing.
    Web Design2018-02-19 21:38 (6天前)回复
  60. obviously like your web-site but you have to check the spelling on several of your posts. Many of them are rife with spelling issues and I find it very bothersome to tell the reality nevertheless I'll certainly come back again.
    Fashion2018-02-20 05:16 (5天前)回复
  61. Thank you so much for providing individuals with an exceptionally splendid possiblity to read articles and blog posts from this web site. It's always very pleasurable and jam-packed with amusement for me personally and my office acquaintances to visit your website on the least three times in one week to read the new guidance you have. And definitely, I'm so actually amazed concerning the remarkable concepts served by you. Selected two areas in this post are without a doubt the best I've had.
    school of arts2018-02-20 13:44 (5天前)回复
  62. Wow, fantastic blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your web site is great, let alone the content!
    smartphone2018-02-20 13:44 (5天前)回复
  63. I am no longer positive where you're getting your info, but great topic. I needs to spend some time studying much more or understanding more. Thanks for fantastic info I was on the lookout for this info for my mission.
    software2018-02-20 13:50 (5天前)回复
  64. Good write-up, I am normal visitor of one¡¦s site, maintain up the excellent operate, and It is going to be a regular visitor for a long time.
    car manufactures2018-02-20 13:53 (5天前)回复
  65. My brother recommended I might like this blog. He was totally right. This post actually made my day. You can not imagine simply how much time I had spent for this info! Thanks!
    Home Improvement2018-02-20 15:59 (5天前)回复
  66. Needed to put you a bit of word so as to thank you so much once again over the superb tips you have contributed on this site. This is seriously open-handed of people like you to offer unhampered all that a lot of people could possibly have supplied as an e book to end up making some profit for themselves, and in particular considering the fact that you might well have tried it in case you desired. These pointers also worked to be a fantastic way to realize that other people have similar desire really like mine to learn a whole lot more with regard to this matter. I am certain there are several more pleasurable occasions up front for individuals who browse through your website.
    Home Improvement2018-02-21 00:29 (5天前)回复
  67. You are a very clever person!
    shopping channel2018-02-21 06:11 (4天前)回复
  68. Thank you a bunch for sharing this with all people you actually know what you are speaking approximately! Bookmarked. Please additionally discuss with my website =). We will have a hyperlink exchange contract between us!
    home remodeling2018-02-21 06:12 (4天前)回复
  69. Very nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. After all I will be subscribing to your feed and I hope you write again soon!
    games2018-02-21 06:12 (4天前)回复
  70. As I web-site possessor I believe the content matter here is rattling fantastic , appreciate it for your hard work. You should keep it up forever! Best of luck.
    home remodeling2018-02-21 06:38 (4天前)回复
  71. I do trust all the ideas you've introduced for your post. They are very convincing and can certainly work. Nonetheless, the posts are very short for beginners. May just you please prolong them a bit from subsequent time? Thanks for the post.
    Travel2018-02-21 08:34 (4天前)回复
  72. As a Newbie, I am always exploring online for articles that can benefit me. Thank you
    build relationship2018-02-21 18:27 (4天前)回复
  73. Thank you for sharing excellent informations. Your site is very cool. I'm impressed by the details that you¡¦ve on this blog. It reveals how nicely you understand this subject. Bookmarked this web page, will come back for more articles. You, my friend, ROCK! I found simply the information I already searched all over the place and simply could not come across. What an ideal web site.
    island2018-02-21 18:30 (4天前)回复
  74. Hey there, You have done an incredible job. I will definitely digg it and personally recommend to my friends. I am sure they will be benefited from this site.
    Jewelry2018-02-21 19:17 (4天前)回复
  75. As soon as I found this website I went on reddit to share some of the love with them.
    Fashion2018-02-22 14:40 (3天前)回复
  76. Thanks for the sensible critique. Me and my neighbor were just preparing to do some research about this. We got a grab a book from our area library but I think I learned more clear from this post. I am very glad to see such fantastic information being shared freely out there.
    Home Improvement2018-02-22 22:30 (3天前)回复
  77. I haven't checked in here for a while because I thought it was getting boring, but the last several posts are good quality so I guess I will add you back to my daily bloglist. You deserve it my friend :)
    Health2018-02-23 06:35 (2天前)回复
  78. wonderful points altogether, you simply won a logo new reader. What could you suggest in regards to your publish that you just made some days in the past? Any certain?
    Health2018-02-23 14:41 (2天前)回复
  79. I view something genuinely interesting about your blog so I bookmarked .
    Web Design2018-02-24 03:12 (1天前)回复
  80. As a Newbie, I am always browsing online for articles that can help me. Thank you
    free voucher2018-02-24 05:20 (1天前)回复
  81. I would like to thank you for the efforts you've put in writing this website. I am hoping the same high-grade web site post from you in the upcoming also. In fact your creative writing skills has encouraged me to get my own blog now. Actually the blogging is spreading its wings fast. Your write up is a great example of it.
    online marketing2018-02-24 05:20 (1天前)回复
  82. It¡¦s really a nice and helpful piece of information. I¡¦m happy that you shared this useful information with us. Please keep us informed like this. Thank you for sharing.
    book flight and hotel2018-02-24 05:22 (1天前)回复
  83. I am so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that is at the other blogs. Appreciate your sharing this best doc.
    Development2018-02-24 05:35 (1天前)回复
  84. Great write-up, I¡¦m normal visitor of one¡¦s website, maintain up the nice operate, and It's going to be a regular visitor for a lengthy time.
    international flights2018-02-24 05:44 (1天前)回复
  85. This is really interesting, You're a very skilled blogger. I've joined your feed and look forward to seeking more of your wonderful post. Also, I have shared your web site in my social networks!
    Business2018-02-24 11:52 (1天前)回复
  86. You made some nice points there. I did a search on the issue and found most people will agree with your site.
    Real Estate2018-02-24 12:01 (1天前)回复
  87. Nice weblog here! Additionally your web site rather a lot up very fast! What web host are you the usage of? Can I get your affiliate hyperlink on your host? I wish my site loaded up as fast as yours lol
    Travel2018-02-24 12:03 (1天前)回复
  88. I do accept as true with all of the ideas you've presented to your post. They're really convincing and will certainly work. Nonetheless, the posts are too quick for starters. Could you please prolong them a bit from next time? Thanks for the post.
    Digital Marketing2018-02-24 12:04 (1天前)回复
  89. Hey very nice site!! Man .. Beautiful .. Wonderful .. I will bookmark your blog and take the feeds additionally…I'm glad to seek out a lot of helpful information here in the publish, we want develop extra strategies in this regard, thanks for sharing.
    Home Improvement2018-02-24 12:59 (1天前)回复
  90. I was recommended this web site by my cousin. I'm not sure whether this post is written by him as no one else know such detailed about my trouble. You are wonderful! Thanks!
    Travel2018-02-24 20:48 (17小时前)回复
  91. Hi there very cool web site!! Guy .. Excellent .. Superb .. I'll bookmark your web site and take the feeds also…I'm satisfied to find a lot of helpful info right here within the publish, we need develop more techniques in this regard, thank you for sharing.
    Business2018-02-25 06:44 (7小时前)回复