将运算符导入函数

时间:2015-12-06 21:31:53

标签: python function

我有这段代码:

if sudo_prob[a][b][0] in column[x] and x!=a:
    column[x].remove(sudo_prob[a][b][0])
if sudo_prob[a][b][0] in line[x] and x!=b:
    line[x].remove(sudo_prob[a][b][0])
if sudo_prob[a][b][0] in square[x] and (x%3!=b%3) and (a%3!=0+(x>2)+(x>5)):
    square[x].remove(sudo_prob[a][b][0])

除了变量调用' d(行/列/平方)和条件(x!= a / x!= b ...)之外,它的操作相同

有没有办法调用一个函数,该函数将参数变量&条件?

1 个答案:

答案 0 :(得分:0)

将公共部分提取到函数中:

Dim tempsql As String
Dim rs As DAO.Recordset
Dim webAddress As String

tempsql = "Select real_address from propertyData"
Set rs = CurrentDb.OpenRecordset(tempsql)


webAddress = "http://maps.googleapis.com/maps/api/staticmap?"
webAddress = webAddress & "center=Athens,Greece&zoom=myzoom&size=800x1200&"

Do While Not rs.EOF
webAddress = webAddress & "markers=color:red%7Clabel: %7C" & rs.Fields(0).Value & "&"
rs.MoveNext
Loop
webAddress = webAddress & "sensor=false"