列表作为函数参数
列表作为函数参数,函数中可以修改原列表
def multiply(values,factor): for i in range(len(values)): values[i]*=factor aList=[1,2,3,4,5] multiply(aList,2) print(aList)
>>>[2,4,6,810
Python中int,float,str均为不可变对象,list为可变对象。
列表作为函数参数,函数中可以修改原列表
def multiply(values,factor): for i in range(len(values)): values[i]*=factor aList=[1,2,3,4,5] multiply(aList,2) print(aList)
>>>[2,4,6,810
Python中int,float,str均为不可变对象,list为可变对象。
math库包括4个数学常数math.pi 圆周率math.e 自然对数math.inf 正无穷大,负无穷大为-math.infmath.nan 非浮点数标记math库常用函数math.cell(x) 向上取整,返回不小于x的最小整数math.facto...
random() 生成一个[0.0,1.0)之间的随机小数randint(a,b) 生成一个[a,b]之间的整数uniform(a,b) 生成一个[a,b]之间的随机小数对random库的引用方法与math库一样,采用下面两种方式实现:import random...
随机生成100个小写字母存入一个列表中,统计26个字母的出现次数。import random def getRandomLetter(): code_a=ord('a') code_z=ord('z') x=random.randint(code_a,code_z)...
使用python运行from PIL import Image from pathlib import Path import os path = r'.' ...
import os import time import argparse import requests import re import io from urllib.parse import ...
import argparse import time from urllib.parse import urljoin, urlparse from selenium import webdriver...