Python--day 1

 俗话说的好,掌握一门语言要从掌握 print("hello world")开始
 1 print("hello world")
 2 #变量
 3 name = "GTT"
 4 name1 = name
 5 print("My name is ", name, name1)
 6 name = "WZ"
 7 print("My name is ", name, name1)
 8 msg ='''
 9 name1通过name直接找到数据所在的地址
10 变量名一定要有名义
11 python中没有常量的概念 一般大写代表常量
12 ------------------------------------------
13 '''
14 
15 #字符编码 Unicode
16 #UTF-8是对Unicode的优化
17 print("你好 世界!")
18 print(msg)
19 
20 #用户输入
21 username = input("username:")
22 userpasswd = input("passwd:")
23 print(username, userpasswd)
24 
25 name = input("name:")
26 age =  input("age:")
27 job =  input("job:")
28 salay =  input("salay:")
29 
30 #字符串拼接
31 info='''
32 ----------info of '''+ name +'''----------
33 Name:'''+ name +'''
34 Age:'''+ age +'''
35 job:'''+ job+'''
36 salay:'''+ salay +''''''
37 print(info)
38 #info在内存中开辟多个内存空间 效率低
39 
40 info1='''
41 ----------info1 of %s----------
42 Name:%s
43 Age:%s
44 job:%s
45 salay:%s
46 ''' % (name, name, age, job, salay)
47 print(info1)
48 #%d %f 也是可以的 这样可以帮助监测数据类型
49 #input默认输入的都是字符串,python强类型定义语言 需要强转
50 #age = int(input("age:"))
51 
52 info2 = '''
53 ----------info2 of {_name}----------
54 Name:{_name}
55 Age:{_age}
56 job:{_job}
57 salay:{_salay}
58 '''.format(_name=name, _age=age, _job=job, _salay=salay)
59 print(info2)
60 
61 info3 = '''
62 ----------info3 of {0}----------
63 Name:{0}
64 Age:{1}
65 job:{2}
66 salay:{3}
67 '''.format(name, age, job, salay)
68 print(info3)

 

posted @ 2019-01-09 17:23  T大帅  阅读(161)  评论(0编辑  收藏  举报