标签:
1 #!/usr/bin/env python 2 # Author: Leon xie 3 4 print("Hello World!!") 5
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 name = "xie di" 5 age = 21 6 7 print(name ,age) 8 输出效果 9 xie di 21 10 11 Process finished with exit code 0
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 v1 = "xiedi" 5 v2 = 21 6 7 print(v1,v2) 8 输出效果 9 xiedi 21 10 11 Process finished with exit code 0
age_of_xiedi = 24
AgeOfXieDi
age-of-xiedi
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 name = "xiedi" 5 name2 = name 6 print(name2,name) 7 8 输出结果为 9 xiedi xiedi
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 4 name = "xiedi" 5 name2 = name 6 print(name,name) 7 8 name = ‘banzhuan‘ 9 10 print(name,name2) 11 12 输出结果却是 13 xiedi xiedi 14 banzhuan xiedi
图示已经很清楚了,我就不做过多解释了。
#name = "xiedi"
第二种:
‘‘‘ 每行最多80个字符 name = "xie di" age = 21 print(name ,age) ‘‘‘
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author: Leon xie user_input = input("pls enter you name:") print("my name is",user_input) 执行结果 pls enter you name:xiedi my name is xiedi
很简单是不是,来我们接着打关升级..........
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # Author: Leon xie 4 5 name = input("pls enter you name:") 6 age = input("pls enter you age:") 7 job = input("pls enter job:") 8 9 print("my name is",name) 10 print("my age is",age) 11 print("my job is",job) 12 13 输出结果 14 pls enter you name:xiedi 15 pls enter you age:21 16 pls enter job:it 17 my name is xiedi 18 my age is 21 19 my job is it
1 #!/usr/bin/env python 2 # -*- coding:utf-8 -*- 3 # Author: Leon xie 4 5 name = input("pls enter you name:") 6 age = input("pls enter you age:") 7 job = input("pls enter job:") 8 9 msg = ‘‘‘ 10 info of user %s 11 ================== 12 13 Name : %s 14 Age : %d 15 Job : %s 16 17 =======End=========== 18 ‘‘‘%(name,name,age,job) 19 20 print(msg) 21 22 输出结果 23 pls enter you name:xiedi 24 pls enter you age:22 25 pls enter job:it 26 Traceback (most recent call last): 27 File "C:/Users/linux/PycharmProjects/study14/day1/t1.py", line 22, in <module> 28 ‘‘‘%(name,name,age,job) 29 TypeError: %d format: a number is required, not str 30 31 Process finished with exit code 1
1 age = int(input("pls enter you age:"))
1 pls enter you name:xiedi 2 pls enter you age:22 3 pls enter job:it 4 5 info of user xiedi 6 ================== 7 8 Name : xiedi 9 Age : 22 10 Job : it 11 12 =======End===========
完美!!
遇见python的helloworld(一个初学者的心酸路程)
标签:
原文地址:http://www.cnblogs.com/jixuege-1/p/5701089.html