换行的:
# -*- coding: utf-8 -*-
#!/usr/bin/env python
conuter = 111111
while conuter < 111501:
print '%d;' %(conuter)
conuter+=1
不换行的:
# -*- coding: utf-8 -*-
#!/usr/bin/env python
strEnd = ""
strConver=""
conuter = 111111
while conuter < 111501:
strEnd = strEnd + str(conuter) + ';'
conuter+=1
print strEnd
输出文本的:
# -*- coding: utf-8 -*-
#!/usr/bin/env python
strEnd = ""
strConver=""
conuter = 111111
while conuter < 111501:
strEnd = strEnd + str(conuter) + ';'
conuter+=1
fileHandle = file('1.txt','w')
fileHandle.write(strEnd)
fileHandle.close
print strEnd
本文通过Python示例代码展示了如何使用while循环进行数值递增打印及字符串拼接,并将结果输出到文件中。涉及Python基本语法如变量定义、条件判断、文件操作等。
5589

被折叠的 条评论
为什么被折叠?



