python3 If 语句
python3 If 语句 #!/usr/bin/python3 var1 = 100 if var1: print ("1 - Got a true expression value") print (var1) var2 = 0 if var2: print ("2 - Got a true expression value") print (var2) print ("Good bye!")
阅读全文 ↗python3 If 语句 #!/usr/bin/python3 var1 = 100 if var1: print ("1 - Got a true expression value") print (var1) var2 = 0 if var2: print ("2 - Got a true expression value") print (var2) print ("Good bye!")
阅读全文 ↗Python3 文件File Isatty 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) ret = fo.isatty() print ("Return value : ", ret) # Close opend file fo.close()
阅读全文 ↗Python3 Fileno 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) fid = fo.fileno() print ("File Descriptor: ", fid) # Close opend file fo.close()
阅读全文 ↗Python3 文件File Flush 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) # Here it does nothing, but you can call it with read operation. fo.flush() # Close opend file fo.close()
阅读全文 ↗Python3 文件File Close 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) # Close opened file fo.close()
阅读全文 ↗Python3 文件File位置 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "r+") str = fo.read(10) print ("Read String is : ", str) # Check current position position = fo.tell() print ("Current file position : ", position) # Reposition pointer at the beginning once again position = fo.seek(0, 0) str = fo.read(10) print ("Again read String is : ", str) # Close opened file fo.close()
阅读全文 ↗Python3 Read 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "r+") str = fo.read(10) print ("Read String is : ", str) # Close opened file fo.close()
阅读全文 ↗Python3 Write 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "w") fo.write( "Python is a great language.\nYeah its great!!\n") # Close opend file fo.close()
阅读全文 ↗Python3 Close 方法 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) # Close opened file fo.close()
阅读全文 ↗Python3 文件File对象属性 #!/usr/bin/python3 # Open a file fo = open("foo.txt", "wb") print ("Name of the file: ", fo.name) print ("Closed or not : ", fo.closed) print ("Opening mode : ", fo.mode) fo.close()
阅读全文 ↗Python3 当行语句 #!/usr/bin/python3 var = 100 if ( var == 100 ) : print ("Value of expression is 100") print ("Good bye!")
阅读全文 ↗Python3 Dir 函数 #!/usr/bin/python3 # Import built-in module math import math content = dir(math) print (content)
阅读全文 ↗