1.raw_input input
2. If you want to see the use of a keyword, you can enter Pydoc raw_input at the command line.
If it's windows, then try Python-m pydoc raw_input
3. Parameters, unpacking, variables
Run the following code, enter $ python ex13.py first 2nd 3rd
From sys import ARGV
Script, first, second, third = argv #argv包含了所有传递给它的参数
Print "The script is called:", script #ex13. py
Print "Your first variable is:", first #first
Print "Your second variable is:", second #2nd
Print "Your third variable is:", third #3rd
4. Tips and Delivery
such as: Likes=raw_input (' Please enter the name you like ')
Or: prompt= ' >>> '
Likes=raw_input (Prompt)
The above notation indicates the prompt in front of the input.
5. close– Close the file. Save it with your editor's file. a meaning.
read– reads the contents of the file. You can assign the result to a variable.
readline– reads a line in a text file.
truncate– Empty The file, use this command with care.
Write (stuff) – writes stuff to the file.
--------------------------------------------------------
#-*-Coding:utf-8-*-
Filename=raw_input ("Please enter your file name:")
Filetxt=open (filename, ' W ') #因为要进行写入参数, so you need to identify the W when you open the file
print "Deleting original file Contents"
Filetxt.truncate ()
Print "Delete Complete"
Filecontent=raw_input ("Please enter a new content:")
Filetxt.write (filecontent)
Filetxt.write ("\ n")
Filetxt.write (filecontent)
Filetxt.close ()
-----------------------------------------
In addition to ' W ', there is ' r ' for reading, ' A ' means append
If only the open (filename) is written, then the ' R ' mode is used by default.
Python syntax two