mirror of
https://github.com/JamesonHuang/OpenWrt_Luci_Lua.git
synced 2024-11-23 22:00:11 +00:00
test python strcat & foreach
This commit is contained in:
parent
1c19757bd8
commit
c03b580461
25
2_0.python_test/foreach_test.py
Normal file
25
2_0.python_test/foreach_test.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# coding=utf-8
|
||||||
|
|
||||||
|
#遍历字符串每个字符
|
||||||
|
word = 'helloworld!'
|
||||||
|
str = "strcat method4: "
|
||||||
|
for letter in word:
|
||||||
|
print "strcat method1: " + letter
|
||||||
|
print "strcat method2: ", letter
|
||||||
|
print "strcat method3: %s" %(letter)
|
||||||
|
#print str.join(letter) #fail
|
||||||
|
|
||||||
|
#遍历数组元素
|
||||||
|
words = ['hello', 'world']
|
||||||
|
for word in words:
|
||||||
|
print "word:",word
|
||||||
|
|
||||||
|
#for(int i = 0; i < 10; i += 2)
|
||||||
|
for num in range(0, 10, 2):
|
||||||
|
print num
|
||||||
|
|
||||||
|
#index
|
||||||
|
for index in range(len(words)):
|
||||||
|
print words[index]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user