I. Notes
Current line Comment: # Annotated content
Multiline Comment: "" "Annotated Content" ""
Second, user input
#!/usr/bin/env python
#_ *_coding:utf-8_*_
#name = Raw_input ("What is your name?") #only on python 2.x
name = i Nput ("What is your name?")
Print ("Hello" + name)
When you enter a password, if you want to be visible, you need to take advantage of the Getpass method in the Getpass module, namely:
#!/usr/bin/env python
#-*-coding:utf-8-*-
import getpass
# Assign user-entered content to name variable
pwd = Getpass.getp Ass ("Please enter a password:")
# Print the content printed
(PWD)
Third, format string
Formatted output of strings
Name = "Alex"
print "I am%s"% name
# output: I am Alex
PS: string is%s; integer%d; floating point number%f
Iv. Initial understanding of the module
The power of Python is that he has very rich and powerful standard libraries and third-party libraries, and that almost any functionality you want to implement has a corresponding Python library support.
#!/usr/bin/env python
#-*-coding:utf-8-*-
import os
os.system ("Df-h") #调用系统命令
Write your own tab module, you will find that the above written tab.py module can only be imported in the current directory, if you want to be in the system where to use how to do it?
At this point you have to put this tab.py into the Python Global environment variable directory, basically in a directory called Python/2.7/site-packages, the directory in different OS place is not the same, with print (Sys.path) You can view a list of Python environment variables.
The above is a small set to introduce the basics of Python user input and the beginning of the module to understand, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!