ทำได้แล้วแบบนี้ค่ะ
โค้ด: เลือกทั้งหมด
def n_std(self,ids):
_logger.debug('debug n_std() %r',ids)
str = ''
for id in ids:
str = str + id.name + ','
return str
Moderator: mindphp, ผู้ดูแลกระดาน
โค้ด: เลือกทั้งหมด
def n_std(self,ids):
_logger.debug('debug n_std() %r',ids)
str = ''
for id in ids:
str = str + id.name + ','
return str
โค้ด: เลือกทั้งหมด
def n_std(self,ids):
str = []
for id in ids:
str.append(id.name) #ยัดค่า loop เเต่ละรอบเข้าในตัวแปลเดียว ใน python จะใช้ .append()
text = self.implode(str) #จากเอาค่าที่ได้ มาเข้า function
return text
def implode(self,str):
text = ",".join(str)#คำส่งนี้เป็นคำสั่งตัดแบ่ง list ออกมาโดยเราสามารถกำหนดเครื่องหมาย ได้ว่าจะให้คั่นด้วยอะไร ใน " "
return text
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 75