1.
Print ("Hello word") after Python3, print needs to be added () to output
2.
Guess_age =intInput"Guess Age:") input data entered by default is a string type, if the bottom is to be a numeric type of calculation, you need to cast to the int type
3.
Elif equivalent to else if
4.
PrintType (age))#str输出age的数据类型
5.# Formatted Output
Name= ""
Age= ""
Job= ""
Salary= ""
(1) Stitching strings (not recommended)
info=‘‘‘
------------info of "' +name+‘‘‘‘---------
Name: "+age+"‘‘‘
Age: "' +job
(2) through placeholder%s
info=‘‘‘
---------------Info of%s-------------
name:%s
age:%s
job:%s
salary:%s
"% (name,name,age,job,salary)
(3) How to assign a value
Info2=‘‘‘
---------------info of {_name}-------------
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
". Format (_name=name,
_age=age,
_job=job,
_salary=salary)
(4)
info3=‘‘‘
-------info of {0}------
NAME:{0}
Age:{1}
JOB:{2}
SALARY:{3}
". Format (name,age,job,salary)
6.
Import GetpassAfter importing the Getpass package, the password can be used in encrypted form
7.
Import Login#1. Directly invoke the login method in the current directory, login is the py file written by itself
#2. You can copy login to E:\baoshun\GOdoo11\runtime\Python35\Lib\site-packages site-package and call it directly.
8.
Import Sys
# print (Sys.path) #打印环境变量
Print (SYS.ARGV)#打印出了当前节点的绝对路径和参数
Print (sys.argv[2])#输出第二个参数
#跟系统模块交互比较多
Import OS
Cmd_res=os.system ("DIR")#输出当前路径下的文件, executes the command, does not save the result, displays 0 after output
Print"----->", cmd_res)#输出-----> 0, indicating successful output
Cmd_res1=os.popen ("dir"). Read ()#没有read显示文件的内存地址
Print"----->", cmd_res1)
Os.mkdir ("New_dir")#向目录下边创建一个新文件 (can be seen on the left side of the current page day1 below)
9. String encode into bite type, bite type can be decode into string type
msg="I love Beijing Tian ' an door"
PrintMsg.encode (encoding="Utf-8"))#应写上你原来的编码规则, the default is Utf-8 in Python3, so do not write.
PrintMsg.encode (encoding="Utf-8"). Decode (encoding="Utf-8"))
Print (b\xe6\x88\x91\xe7\x88\xb1\xe5\x8c\x97\xe4\xba\xac\xe5\xa4\xa9\xe5\xae\x89\xe9\x97\xa8'). Decode (encoding="Utf-8"))
10.for Cycle Printing
For I in range (10):
Print ("Loop", i)
# Number of intervals to print
For a in range (0,10,2):
Print ("Loop", a)
For b in Range (0,10):
If b<3:
Print ("loop", b)
Else
# countinue ends the loop, break ends the current loop
Continue
print ("hehe ...")
Python first day