ทำได้แล้วแบบนี้ค่ะ
Code: Select all
def n_std(self,ids):
_logger.debug('debug n_std() %r',ids)
str = ''
for id in ids:
str = str + id.name + ','
return str
Moderators: mindphp, ผู้ดูแลกระดาน
Post by dawthana » 23/02/2017 5:55 pm
Code: Select all
def n_std(self,ids):
_logger.debug('debug n_std() %r',ids)
str = ''
for id in ids:
str = str + id.name + ','
return str
Post by thatsawan » 23/02/2017 6:00 pm
Code: Select all
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
Post by mindphp » 23/02/2017 6:03 pm
Users browsing this forum: No registered users and 3 guests