Python 练习实例

来自linux中国网wiki
跳到导航 跳到搜索

CGI

github/python/project/chapter25CGI/2024

98


cat 98.py 
#!/usr/bin/python
# -*- coding: utf-8 -*-
#py2
if __name__ == '__main__':
    fp = open('test.txt','w')
    string = raw_input('please input a string:\n')
    string = string.upper()
    fp.write(string)
    fp = open('test.txt','r')
    print fp.read()
    fp.close()


#py3 
#在 Python3.x 中 raw_input( ) 和 input( ) 进行了整合,去除了 raw_input( ),仅保留了 input( ) 函数,其接收任意任性输入,将所有输入默认为字符串处理,并返回字符串类型






see also

https://www.runoob.com/python3/python3-upper-lower.html