Step by Step Learn Python(1)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | print "Hello World!" action = raw_input ( "please select your action{1, 2, 3, 4, 5, 6, 7, 8, 9, o}: " ) print action if action = = str ( "1" ): #print hello name name = raw_input ( "what's your name? " ) print "Hello " + name elif action = = str ( "2" ): #print hu and chongshi hu = [ "hu" , 25 ] chongshi = [ "chongshi" , 32 ] database = [hu, chongshi] print database elif action = = "3" : greeting = "chongshi" #print c print greeting[ 0 ] elif action = = "4" : fourth = raw_input ( "year:" )[ 3 ] #year:2013 print 3 print fourth elif action = = "5" : tag = '<a href="http://www.python.org">Python web site</a>' print tag[ 9 : 30 ] print tag[ 32 : - 4 ] elif action = = "6" : permissions = "rw" print "w" in permissions users = [ "hls" , "lisi" ] r = raw_input ( "enter you user name:" ) in users #return true or false check input value is not at users print r elif action = = "7" : numbers = [ 100 , 34 , 678 ] print "max(numbers) " + str ( max (numbers)) #get max value for numbers print "min(numbers) " + str ( min (numbers)) #get min value for numbers elif action = = "8" : lis = list ( 'chongshi' ) x = [ 1 , 3 , 4 ] x[ 1 ] = 2 print x #update item value del x[ 1 ] #delete a item print x x[ 1 :] = list ( "111v123" ) #append a list at index 1 of x print x print 'there have ' + str (x.count( "1" )) + ' "1"' #get contains "1" of list x's value y = [ 4 , 5 , 6 , 7 , 8 ] x.extend(y) #extend y to x print x print x.index( "1" ) #get index for "1" x.insert( 5 , "5.5" ) #insert a value at index 5 later print x x.pop() #delete a last item print x x.pop( 1 ) #delete index 1's value print x x.remove() #delete a first item print x x.reverse() #reverse items print x x.sort() print x elif action = = "9" : #tuple z = 1 , 2 , 3 print z z = tuple ( "12346abc" ) print z else : print '''this is a very long string. It continues here. and it's not over yet.''' |
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决