文章浏览阅读205次。1. 操作系统接口>>> import os>>> os.getcwd() # Return the current working directory'C:\\Python38'>>> os.chdir('/server/accesslogs') # Change current working directory>>> os.system('mkdir today') # Run the command _python基......
文章浏览阅读229次。1. 定义函数1.1字符串文档函数体的第一个语句可以(可选的)是字符串文字;这个字符串文字是函数的文档字符串或 docstring。>>> def fib(n): # write Fibonacci series up to n... """Print a Fibonacci ser......
文章浏览阅读165次。>>> while True:... try:... x = int(input("Please enter a number: "))... break... except ValueError:... print("Oops! That was no valid number. Try again...")...except 可以多行except 子句的元组... except......
文章浏览阅读104次。1. 序列序列有三种基本序列类型:list, tuple 和 range 对象。2. 元祖元组由几个被逗号隔开的值组成>>> t = 12345, 54321, 'hello!'>>> t[0]12345>>> t(12345, 54321, 'hello!')>>> # Tuples may be nested:... u = t, ......